OLD | NEW |
1 // Copyright 2014 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 <memory> | 10 #include <memory> |
10 | 11 |
11 #include "core/fxcrt/include/fx_ext.h" | 12 #include "core/fxcrt/include/fx_ext.h" |
12 #include "fxjs/include/cfxjse_arguments.h" | 13 #include "fxjs/include/cfxjse_value.h" |
13 #include "third_party/base/stl_util.h" | 14 #include "third_party/base/stl_util.h" |
14 #include "xfa/fde/xml/fde_xml_imp.h" | 15 #include "xfa/fde/xml/fde_xml_imp.h" |
15 #include "xfa/fgas/crt/fgas_codepage.h" | 16 #include "xfa/fgas/crt/fgas_codepage.h" |
16 #include "xfa/fgas/crt/fgas_system.h" | 17 #include "xfa/fgas/crt/fgas_system.h" |
17 #include "xfa/fxfa/app/xfa_ffnotify.h" | 18 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 19 #include "xfa/fxfa/include/cxfa_eventparam.h" |
18 #include "xfa/fxfa/parser/cxfa_occur.h" | 20 #include "xfa/fxfa/parser/cxfa_occur.h" |
19 #include "xfa/fxfa/parser/cxfa_simple_parser.h" | 21 #include "xfa/fxfa/parser/cxfa_simple_parser.h" |
20 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 22 #include "xfa/fxfa/parser/xfa_basic_data.h" |
21 #include "xfa/fxfa/parser/xfa_doclayout.h" | |
22 #include "xfa/fxfa/parser/xfa_document.h" | 23 #include "xfa/fxfa/parser/xfa_document.h" |
23 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 24 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
24 #include "xfa/fxfa/parser/xfa_localemgr.h" | |
25 #include "xfa/fxfa/parser/xfa_script.h" | |
26 #include "xfa/fxfa/parser/xfa_script_imp.h" | 25 #include "xfa/fxfa/parser/xfa_script_imp.h" |
27 #include "xfa/fxfa/parser/xfa_utils.h" | |
28 | 26 |
29 namespace { | 27 namespace { |
30 | 28 |
31 void XFA_DeleteWideString(void* pData) { | 29 void XFA_DeleteWideString(void* pData) { |
32 delete static_cast<CFX_WideString*>(pData); | 30 delete static_cast<CFX_WideString*>(pData); |
33 } | 31 } |
34 | 32 |
35 void XFA_CopyWideString(void*& pData) { | 33 void XFA_CopyWideString(void*& pData) { |
36 if (pData) { | 34 if (pData) { |
37 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); | 35 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); |
38 pData = pNewData; | 36 pData = pNewData; |
39 } | 37 } |
40 } | 38 } |
41 | 39 |
42 XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString, | 40 XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString, |
43 XFA_CopyWideString}; | 41 XFA_CopyWideString}; |
44 | 42 |
45 void XFA_DataNodeDeleteBindItem(void* pData) { | 43 void XFA_DataNodeDeleteBindItem(void* pData) { |
46 delete static_cast<CXFA_NodeArray*>(pData); | 44 delete static_cast<CXFA_NodeArray*>(pData); |
47 } | 45 } |
48 | 46 |
49 XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { | 47 XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { |
50 XFA_DataNodeDeleteBindItem, nullptr}; | 48 XFA_DataNodeDeleteBindItem, nullptr}; |
51 | 49 |
| 50 int32_t GetCount(CXFA_Node* pInstMgrNode) { |
| 51 ASSERT(pInstMgrNode); |
| 52 int32_t iCount = 0; |
| 53 uint32_t dwNameHash = 0; |
| 54 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 55 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 56 XFA_Element eCurType = pNode->GetElementType(); |
| 57 if (eCurType == XFA_Element::InstanceManager) |
| 58 break; |
| 59 if ((eCurType != XFA_Element::Subform) && |
| 60 (eCurType != XFA_Element::SubformSet)) { |
| 61 continue; |
| 62 } |
| 63 if (iCount == 0) { |
| 64 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
| 65 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); |
| 66 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || |
| 67 wsInstName.Mid(1) != wsName) { |
| 68 return iCount; |
| 69 } |
| 70 dwNameHash = pNode->GetNameHash(); |
| 71 } |
| 72 if (dwNameHash != pNode->GetNameHash()) |
| 73 break; |
| 74 |
| 75 iCount++; |
| 76 } |
| 77 return iCount; |
| 78 } |
| 79 |
| 80 void SortNodeArrayByDocumentIdx(const CXFA_NodeSet& rgNodeSet, |
| 81 CXFA_NodeArray& rgNodeArray, |
| 82 CFX_ArrayTemplate<int32_t>& rgIdxArray) { |
| 83 int32_t iCount = pdfium::CollectionSize<int32_t>(rgNodeSet); |
| 84 rgNodeArray.SetSize(iCount); |
| 85 rgIdxArray.SetSize(iCount); |
| 86 if (iCount == 0) |
| 87 return; |
| 88 |
| 89 int32_t iIndex = -1; |
| 90 int32_t iTotalIndex = -1; |
| 91 CXFA_Node* pCommonParent = |
| 92 (*rgNodeSet.begin())->GetNodeItem(XFA_NODEITEM_Parent); |
| 93 for (CXFA_Node* pNode = pCommonParent->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 94 pNode && iIndex < iCount; |
| 95 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 96 iTotalIndex++; |
| 97 if (pdfium::ContainsValue(rgNodeSet, pNode)) { |
| 98 iIndex++; |
| 99 rgNodeArray[iIndex] = pNode; |
| 100 rgIdxArray[iIndex] = iTotalIndex; |
| 101 } |
| 102 } |
| 103 } |
| 104 |
| 105 using CXFA_NodeSetPair = std::pair<CXFA_NodeSet, CXFA_NodeSet>; |
| 106 using CXFA_NodeSetPairMap = |
| 107 std::map<uint32_t, std::unique_ptr<CXFA_NodeSetPair>>; |
| 108 using CXFA_NodeSetPairMapMap = |
| 109 std::map<CXFA_Node*, std::unique_ptr<CXFA_NodeSetPairMap>>; |
| 110 |
| 111 CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, |
| 112 CXFA_NodeSetPairMapMap* pMap) { |
| 113 CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 114 uint32_t dwNameHash = pNode->GetNameHash(); |
| 115 if (!pParentNode || !dwNameHash) |
| 116 return nullptr; |
| 117 |
| 118 if (!(*pMap)[pParentNode]) |
| 119 (*pMap)[pParentNode].reset(new CXFA_NodeSetPairMap); |
| 120 |
| 121 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get(); |
| 122 if (!(*pNodeSetPairMap)[dwNameHash]) |
| 123 (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair); |
| 124 |
| 125 return (*pNodeSetPairMap)[dwNameHash].get(); |
| 126 } |
| 127 |
| 128 void ReorderDataNodes(const CXFA_NodeSet& sSet1, |
| 129 const CXFA_NodeSet& sSet2, |
| 130 FX_BOOL bInsertBefore) { |
| 131 CXFA_NodeSetPairMapMap rgMap; |
| 132 for (CXFA_Node* pNode : sSet1) { |
| 133 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); |
| 134 if (pNodeSetPair) |
| 135 pNodeSetPair->first.insert(pNode); |
| 136 } |
| 137 for (CXFA_Node* pNode : sSet2) { |
| 138 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); |
| 139 if (pNodeSetPair) { |
| 140 if (pdfium::ContainsValue(pNodeSetPair->first, pNode)) |
| 141 pNodeSetPair->first.erase(pNode); |
| 142 else |
| 143 pNodeSetPair->second.insert(pNode); |
| 144 } |
| 145 } |
| 146 for (const auto& iter1 : rgMap) { |
| 147 CXFA_NodeSetPairMap* pNodeSetPairMap = iter1.second.get(); |
| 148 if (!pNodeSetPairMap) |
| 149 continue; |
| 150 |
| 151 for (const auto& iter2 : *pNodeSetPairMap) { |
| 152 CXFA_NodeSetPair* pNodeSetPair = iter2.second.get(); |
| 153 if (!pNodeSetPair) |
| 154 continue; |
| 155 if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) { |
| 156 CXFA_NodeArray rgNodeArray1; |
| 157 CXFA_NodeArray rgNodeArray2; |
| 158 CFX_ArrayTemplate<int32_t> rgIdxArray1; |
| 159 CFX_ArrayTemplate<int32_t> rgIdxArray2; |
| 160 SortNodeArrayByDocumentIdx(pNodeSetPair->first, rgNodeArray1, |
| 161 rgIdxArray1); |
| 162 SortNodeArrayByDocumentIdx(pNodeSetPair->second, rgNodeArray2, |
| 163 rgIdxArray2); |
| 164 CXFA_Node* pParentNode = nullptr; |
| 165 CXFA_Node* pBeforeNode = nullptr; |
| 166 if (bInsertBefore) { |
| 167 pBeforeNode = rgNodeArray2[0]; |
| 168 pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 169 } else { |
| 170 CXFA_Node* pLastNode = rgNodeArray2[rgIdxArray2.GetSize() - 1]; |
| 171 pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 172 pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 173 } |
| 174 for (int32_t iIdx = 0; iIdx < rgIdxArray1.GetSize(); iIdx++) { |
| 175 CXFA_Node* pCurNode = rgNodeArray1[iIdx]; |
| 176 pParentNode->RemoveChild(pCurNode); |
| 177 pParentNode->InsertChild(pCurNode, pBeforeNode); |
| 178 } |
| 179 } |
| 180 } |
| 181 pNodeSetPairMap->clear(); |
| 182 } |
| 183 } |
| 184 |
| 185 CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) { |
| 186 ASSERT(pInstMgrNode); |
| 187 int32_t iCount = 0; |
| 188 uint32_t dwNameHash = 0; |
| 189 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 190 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 191 XFA_Element eCurType = pNode->GetElementType(); |
| 192 if (eCurType == XFA_Element::InstanceManager) |
| 193 break; |
| 194 if ((eCurType != XFA_Element::Subform) && |
| 195 (eCurType != XFA_Element::SubformSet)) { |
| 196 continue; |
| 197 } |
| 198 if (iCount == 0) { |
| 199 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
| 200 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); |
| 201 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || |
| 202 wsInstName.Mid(1) != wsName) { |
| 203 return nullptr; |
| 204 } |
| 205 dwNameHash = pNode->GetNameHash(); |
| 206 } |
| 207 if (dwNameHash != pNode->GetNameHash()) |
| 208 break; |
| 209 |
| 210 iCount++; |
| 211 if (iCount > iIndex) |
| 212 return pNode; |
| 213 } |
| 214 return nullptr; |
| 215 } |
| 216 |
| 217 void InsertItem(CXFA_Node* pInstMgrNode, |
| 218 CXFA_Node* pNewInstance, |
| 219 int32_t iPos, |
| 220 int32_t iCount = -1, |
| 221 FX_BOOL bMoveDataBindingNodes = TRUE) { |
| 222 if (iCount < 0) |
| 223 iCount = GetCount(pInstMgrNode); |
| 224 if (iPos < 0) |
| 225 iPos = iCount; |
| 226 if (iPos == iCount) { |
| 227 CXFA_Node* pNextSibling = |
| 228 iCount > 0 |
| 229 ? GetItem(pInstMgrNode, iCount - 1) |
| 230 ->GetNodeItem(XFA_NODEITEM_NextSibling) |
| 231 : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 232 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) |
| 233 ->InsertChild(pNewInstance, pNextSibling); |
| 234 if (bMoveDataBindingNodes) { |
| 235 CXFA_NodeSet sNew; |
| 236 CXFA_NodeSet sAfter; |
| 237 CXFA_NodeIteratorTemplate<CXFA_Node, |
| 238 CXFA_TraverseStrategy_XFAContainerNode> |
| 239 sIteratorNew(pNewInstance); |
| 240 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; |
| 241 pNode = sIteratorNew.MoveToNext()) { |
| 242 CXFA_Node* pDataNode = pNode->GetBindData(); |
| 243 if (!pDataNode) |
| 244 continue; |
| 245 |
| 246 sNew.insert(pDataNode); |
| 247 } |
| 248 CXFA_NodeIteratorTemplate<CXFA_Node, |
| 249 CXFA_TraverseStrategy_XFAContainerNode> |
| 250 sIteratorAfter(pNextSibling); |
| 251 for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode; |
| 252 pNode = sIteratorAfter.MoveToNext()) { |
| 253 CXFA_Node* pDataNode = pNode->GetBindData(); |
| 254 if (!pDataNode) |
| 255 continue; |
| 256 |
| 257 sAfter.insert(pDataNode); |
| 258 } |
| 259 ReorderDataNodes(sNew, sAfter, FALSE); |
| 260 } |
| 261 } else { |
| 262 CXFA_Node* pBeforeInstance = GetItem(pInstMgrNode, iPos); |
| 263 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) |
| 264 ->InsertChild(pNewInstance, pBeforeInstance); |
| 265 if (bMoveDataBindingNodes) { |
| 266 CXFA_NodeSet sNew; |
| 267 CXFA_NodeSet sBefore; |
| 268 CXFA_NodeIteratorTemplate<CXFA_Node, |
| 269 CXFA_TraverseStrategy_XFAContainerNode> |
| 270 sIteratorNew(pNewInstance); |
| 271 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; |
| 272 pNode = sIteratorNew.MoveToNext()) { |
| 273 CXFA_Node* pDataNode = pNode->GetBindData(); |
| 274 if (!pDataNode) |
| 275 continue; |
| 276 |
| 277 sNew.insert(pDataNode); |
| 278 } |
| 279 CXFA_NodeIteratorTemplate<CXFA_Node, |
| 280 CXFA_TraverseStrategy_XFAContainerNode> |
| 281 sIteratorBefore(pBeforeInstance); |
| 282 for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode; |
| 283 pNode = sIteratorBefore.MoveToNext()) { |
| 284 CXFA_Node* pDataNode = pNode->GetBindData(); |
| 285 if (!pDataNode) |
| 286 continue; |
| 287 |
| 288 sBefore.insert(pDataNode); |
| 289 } |
| 290 ReorderDataNodes(sNew, sBefore, TRUE); |
| 291 } |
| 292 } |
| 293 } |
| 294 |
| 295 void RemoveItem(CXFA_Node* pInstMgrNode, |
| 296 CXFA_Node* pRemoveInstance, |
| 297 FX_BOOL bRemoveDataBinding = TRUE) { |
| 298 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance); |
| 299 if (!bRemoveDataBinding) |
| 300 return; |
| 301 |
| 302 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> |
| 303 sIterator(pRemoveInstance); |
| 304 for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode; |
| 305 pFormNode = sIterator.MoveToNext()) { |
| 306 CXFA_Node* pDataNode = pFormNode->GetBindData(); |
| 307 if (!pDataNode) |
| 308 continue; |
| 309 |
| 310 if (pDataNode->RemoveBindItem(pFormNode) == 0) { |
| 311 if (CXFA_Node* pDataParent = |
| 312 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 313 pDataParent->RemoveChild(pDataNode); |
| 314 } |
| 315 } |
| 316 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 317 } |
| 318 } |
| 319 |
| 320 CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, FX_BOOL bDataMerge) { |
| 321 CXFA_Document* pDocument = pInstMgrNode->GetDocument(); |
| 322 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); |
| 323 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 324 CXFA_Node* pDataScope = nullptr; |
| 325 for (CXFA_Node* pRootBoundNode = pFormParent; |
| 326 pRootBoundNode && pRootBoundNode->IsContainerNode(); |
| 327 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 328 pDataScope = pRootBoundNode->GetBindData(); |
| 329 if (pDataScope) |
| 330 break; |
| 331 } |
| 332 if (!pDataScope) { |
| 333 pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); |
| 334 ASSERT(pDataScope); |
| 335 } |
| 336 CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer( |
| 337 pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge, TRUE); |
| 338 if (pInstance) { |
| 339 pDocument->DataMerge_UpdateBindingRelations(pInstance); |
| 340 pFormParent->RemoveChild(pInstance); |
| 341 } |
| 342 return pInstance; |
| 343 } |
| 344 |
| 345 struct XFA_ExecEventParaInfo { |
| 346 public: |
| 347 uint32_t m_uHash; |
| 348 const FX_WCHAR* m_lpcEventName; |
| 349 XFA_EVENTTYPE m_eventType; |
| 350 uint32_t m_validFlags; |
| 351 }; |
| 352 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { |
| 353 {0x02a6c55a, L"postSubmit", XFA_EVENT_PostSubmit, 0}, |
| 354 {0x0ab466bb, L"preSubmit", XFA_EVENT_PreSubmit, 0}, |
| 355 {0x109d7ce7, L"mouseEnter", XFA_EVENT_MouseEnter, 5}, |
| 356 {0x17fad373, L"postPrint", XFA_EVENT_PostPrint, 0}, |
| 357 {0x1bfc72d9, L"preOpen", XFA_EVENT_PreOpen, 7}, |
| 358 {0x2196a452, L"initialize", XFA_EVENT_Initialize, 1}, |
| 359 {0x27410f03, L"mouseExit", XFA_EVENT_MouseExit, 5}, |
| 360 {0x33c43dec, L"docClose", XFA_EVENT_DocClose, 0}, |
| 361 {0x361fa1b6, L"preSave", XFA_EVENT_PreSave, 0}, |
| 362 {0x36f1c6d8, L"preSign", XFA_EVENT_PreSign, 6}, |
| 363 {0x4731d6ba, L"exit", XFA_EVENT_Exit, 2}, |
| 364 {0x56bf456b, L"docReady", XFA_EVENT_DocReady, 0}, |
| 365 {0x7233018a, L"validate", XFA_EVENT_Validate, 1}, |
| 366 {0x8808385e, L"indexChange", XFA_EVENT_IndexChange, 3}, |
| 367 {0x891f4606, L"change", XFA_EVENT_Change, 4}, |
| 368 {0x9528a7b4, L"prePrint", XFA_EVENT_PrePrint, 0}, |
| 369 {0x9f693b21, L"mouseDown", XFA_EVENT_MouseDown, 5}, |
| 370 {0xcdce56b3, L"full", XFA_EVENT_Full, 4}, |
| 371 {0xd576d08e, L"mouseUp", XFA_EVENT_MouseUp, 5}, |
| 372 {0xd95657a6, L"click", XFA_EVENT_Click, 4}, |
| 373 {0xdbfbe02e, L"calculate", XFA_EVENT_Calculate, 1}, |
| 374 {0xe25fa7b8, L"postOpen", XFA_EVENT_PostOpen, 7}, |
| 375 {0xe28dce7e, L"enter", XFA_EVENT_Enter, 2}, |
| 376 {0xfc82d695, L"postSave", XFA_EVENT_PostSave, 0}, |
| 377 {0xfd54fbb7, L"postSign", XFA_EVENT_PostSign, 6}, |
| 378 }; |
| 379 |
| 380 const XFA_ExecEventParaInfo* GetEventParaInfoByName( |
| 381 const CFX_WideStringC& wsEventName) { |
| 382 uint32_t uHash = FX_HashCode_GetW(wsEventName, false); |
| 383 int32_t iStart = 0; |
| 384 int32_t iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1; |
| 385 do { |
| 386 int32_t iMid = (iStart + iEnd) / 2; |
| 387 const XFA_ExecEventParaInfo* eventParaInfo = &gs_eventParaInfos[iMid]; |
| 388 if (uHash == eventParaInfo->m_uHash) |
| 389 return eventParaInfo; |
| 390 if (uHash < eventParaInfo->m_uHash) |
| 391 iEnd = iMid - 1; |
| 392 else |
| 393 iStart = iMid + 1; |
| 394 } while (iStart <= iEnd); |
| 395 return nullptr; |
| 396 } |
| 397 |
| 398 void StrToRGB(const CFX_WideString& strRGB, |
| 399 int32_t& r, |
| 400 int32_t& g, |
| 401 int32_t& b) { |
| 402 r = 0; |
| 403 g = 0; |
| 404 b = 0; |
| 405 |
| 406 FX_WCHAR zero = '0'; |
| 407 int32_t iIndex = 0; |
| 408 int32_t iLen = strRGB.GetLength(); |
| 409 for (int32_t i = 0; i < iLen; ++i) { |
| 410 FX_WCHAR ch = strRGB.GetAt(i); |
| 411 if (ch == L',') |
| 412 ++iIndex; |
| 413 if (iIndex > 2) |
| 414 break; |
| 415 |
| 416 int32_t iValue = ch - zero; |
| 417 if (iValue >= 0 && iValue <= 9) { |
| 418 switch (iIndex) { |
| 419 case 0: |
| 420 r = r * 10 + iValue; |
| 421 break; |
| 422 case 1: |
| 423 g = g * 10 + iValue; |
| 424 break; |
| 425 default: |
| 426 b = b * 10 + iValue; |
| 427 break; |
| 428 } |
| 429 } |
| 430 } |
| 431 } |
| 432 |
| 433 enum XFA_KEYTYPE { |
| 434 XFA_KEYTYPE_Custom, |
| 435 XFA_KEYTYPE_Element, |
| 436 }; |
| 437 |
| 438 void* GetMapKey_Custom(const CFX_WideStringC& wsKey) { |
| 439 uint32_t dwKey = FX_HashCode_GetW(wsKey, false); |
| 440 return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); |
| 441 } |
| 442 |
| 443 void* GetMapKey_Element(XFA_Element eType, XFA_ATTRIBUTE eAttribute) { |
| 444 return (void*)(uintptr_t)((static_cast<int32_t>(eType) << 16) | |
| 445 (eAttribute << 8) | XFA_KEYTYPE_Element); |
| 446 } |
| 447 |
52 } // namespace | 448 } // namespace |
53 | 449 |
54 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, | 450 static void XFA_DefaultFreeData(void* pData) {} |
55 XFA_ObjectType objectType, | 451 |
56 XFA_Element elementType, | 452 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { |
57 const CFX_WideStringC& elementName) | 453 XFA_DefaultFreeData, nullptr}; |
58 : m_pDocument(pDocument), | |
59 m_objectType(objectType), | |
60 m_elementType(elementType), | |
61 m_elementNameHash(FX_HashCode_GetW(elementName, false)), | |
62 m_elementName(elementName) {} | |
63 | |
64 CXFA_Object::~CXFA_Object() {} | |
65 | |
66 CFX_WideStringC CXFA_Object::GetClassName() const { | |
67 return m_elementName; | |
68 } | |
69 | |
70 uint32_t CXFA_Object::GetClassHashCode() const { | |
71 return m_elementNameHash; | |
72 } | |
73 | |
74 XFA_Element CXFA_Object::GetElementType() const { | |
75 return m_elementType; | |
76 } | |
77 | |
78 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, | |
79 FX_BOOL bSetting, | |
80 XFA_ATTRIBUTE eAttribute) { | |
81 if (!bSetting) { | |
82 CFX_WideStringC className = GetClassName(); | |
83 pValue->SetString( | |
84 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); | |
85 } else { | |
86 ThrowException(XFA_IDS_INVAlID_PROP_SET); | |
87 } | |
88 } | |
89 | |
90 void CXFA_Object::ThrowException(int32_t iStringID, ...) { | |
91 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | |
92 ASSERT(pAppProvider); | |
93 CFX_WideString wsFormat; | |
94 pAppProvider->LoadString(iStringID, wsFormat); | |
95 CFX_WideString wsMessage; | |
96 va_list arg_ptr; | |
97 va_start(arg_ptr, iStringID); | |
98 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | |
99 va_end(arg_ptr); | |
100 FXJSE_ThrowMessage( | |
101 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | |
102 } | |
103 | 454 |
104 XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {} | 455 XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {} |
105 | 456 |
106 XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {} | 457 XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {} |
107 | 458 |
108 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, | 459 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, |
109 uint16_t ePacket, | 460 uint16_t ePacket, |
110 XFA_ObjectType oType, | 461 XFA_ObjectType oType, |
111 XFA_Element eType, | 462 XFA_Element eType, |
112 const CFX_WideStringC& elementName) | 463 const CFX_WideStringC& elementName) |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 | 1539 |
1189 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} | 1540 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} |
1190 | 1541 |
1191 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { | 1542 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { |
1192 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); | 1543 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); |
1193 pArguments->GetReturnValue()->SetObject( | 1544 pArguments->GetReturnValue()->SetObject( |
1194 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); | 1545 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
1195 } | 1546 } |
1196 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { | 1547 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { |
1197 } | 1548 } |
| 1549 |
1198 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { | 1550 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { |
1199 Script_Template_CreateNode(pArguments); | 1551 Script_Template_CreateNode(pArguments); |
1200 } | 1552 } |
| 1553 |
1201 void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { | 1554 void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { |
1202 int32_t iLength = pArguments->GetLength(); | 1555 int32_t iLength = pArguments->GetLength(); |
1203 if (iLength < 1) { | 1556 if (iLength < 1) { |
1204 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isCompatibleNS"); | 1557 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isCompatibleNS"); |
1205 return; | 1558 return; |
1206 } | 1559 } |
1207 CFX_WideString wsNameSpace; | 1560 CFX_WideString wsNameSpace; |
1208 if (iLength >= 1) { | 1561 if (iLength >= 1) { |
1209 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); | 1562 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); |
1210 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); | 1563 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); |
1211 } | 1564 } |
1212 CFX_WideString wsNodeNameSpace; | 1565 CFX_WideString wsNodeNameSpace; |
1213 TryNamespace(wsNodeNameSpace); | 1566 TryNamespace(wsNodeNameSpace); |
1214 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 1567 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
1215 if (pValue) | 1568 if (pValue) |
1216 pValue->SetBoolean(wsNodeNameSpace == wsNameSpace); | 1569 pValue->SetBoolean(wsNodeNameSpace == wsNameSpace); |
1217 } | 1570 } |
| 1571 |
1218 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, | 1572 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, |
1219 FX_BOOL bSetting, | 1573 FX_BOOL bSetting, |
1220 XFA_ATTRIBUTE eAttribute) {} | 1574 XFA_ATTRIBUTE eAttribute) {} |
| 1575 |
1221 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, | 1576 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, |
1222 FX_BOOL bSetting, | 1577 FX_BOOL bSetting, |
1223 XFA_ATTRIBUTE eAttribute) {} | 1578 XFA_ATTRIBUTE eAttribute) {} |
| 1579 |
1224 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, | 1580 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, |
1225 FX_BOOL bSetting, | 1581 FX_BOOL bSetting, |
1226 XFA_ATTRIBUTE eAttribute) { | 1582 XFA_ATTRIBUTE eAttribute) { |
1227 if (bSetting) { | 1583 if (bSetting) { |
1228 SetInteger(eAttribute, pValue->ToInteger(), true); | 1584 SetInteger(eAttribute, pValue->ToInteger(), true); |
1229 } else { | 1585 } else { |
1230 pValue->SetInteger(GetInteger(eAttribute)); | 1586 pValue->SetInteger(GetInteger(eAttribute)); |
1231 } | 1587 } |
1232 } | 1588 } |
| 1589 |
1233 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, | 1590 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, |
1234 FX_BOOL bSetting, | 1591 FX_BOOL bSetting, |
1235 XFA_ATTRIBUTE eAttribute) { | 1592 XFA_ATTRIBUTE eAttribute) { |
1236 if (!bSetting) { | 1593 if (!bSetting) { |
1237 pValue->SetInteger(GetInteger(eAttribute)); | 1594 pValue->SetInteger(GetInteger(eAttribute)); |
1238 } else { | 1595 } else { |
1239 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1596 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1240 } | 1597 } |
1241 } | 1598 } |
| 1599 |
1242 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, | 1600 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, |
1243 FX_BOOL bSetting, | 1601 FX_BOOL bSetting, |
1244 XFA_ATTRIBUTE eAttribute) { | 1602 XFA_ATTRIBUTE eAttribute) { |
1245 if (bSetting) { | 1603 if (bSetting) { |
1246 SetBoolean(eAttribute, pValue->ToBoolean(), true); | 1604 SetBoolean(eAttribute, pValue->ToBoolean(), true); |
1247 } else { | 1605 } else { |
1248 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); | 1606 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); |
1249 } | 1607 } |
1250 } | 1608 } |
| 1609 |
1251 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, | 1610 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, |
1252 FX_BOOL bSetting, | 1611 FX_BOOL bSetting, |
1253 XFA_ATTRIBUTE eAttribute) { | 1612 XFA_ATTRIBUTE eAttribute) { |
1254 if (!bSetting) { | 1613 if (!bSetting) { |
1255 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); | 1614 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); |
1256 } else { | 1615 } else { |
1257 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1616 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1258 } | 1617 } |
1259 } | 1618 } |
1260 | 1619 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 delete pProtoForm; | 1829 delete pProtoForm; |
1471 } | 1830 } |
1472 } | 1831 } |
1473 } else { | 1832 } else { |
1474 CFX_WideString wsValue; | 1833 CFX_WideString wsValue; |
1475 GetAttribute(eAttribute, wsValue); | 1834 GetAttribute(eAttribute, wsValue); |
1476 pValue->SetString( | 1835 pValue->SetString( |
1477 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 1836 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
1478 } | 1837 } |
1479 } | 1838 } |
| 1839 |
1480 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, | 1840 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, |
1481 FX_BOOL bSetting, | 1841 FX_BOOL bSetting, |
1482 XFA_ATTRIBUTE eAttribute) { | 1842 XFA_ATTRIBUTE eAttribute) { |
1483 if (!bSetting) { | 1843 if (!bSetting) { |
1484 CFX_WideString wsValue; | 1844 CFX_WideString wsValue; |
1485 GetAttribute(eAttribute, wsValue); | 1845 GetAttribute(eAttribute, wsValue); |
1486 pValue->SetString( | 1846 pValue->SetString( |
1487 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 1847 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
1488 } else { | 1848 } else { |
1489 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1849 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1490 } | 1850 } |
1491 } | 1851 } |
| 1852 |
1492 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { | 1853 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { |
1493 int32_t argc = pArguments->GetLength(); | 1854 int32_t argc = pArguments->GetLength(); |
1494 if ((argc == 0) || (argc == 1)) { | 1855 if ((argc == 0) || (argc == 1)) { |
1495 pArguments->GetReturnValue()->SetBoolean(FALSE); | 1856 pArguments->GetReturnValue()->SetBoolean(FALSE); |
1496 } else { | 1857 } else { |
1497 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); | 1858 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); |
1498 } | 1859 } |
1499 } | 1860 } |
| 1861 |
1500 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { | 1862 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { |
1501 int32_t argc = pArguments->GetLength(); | 1863 int32_t argc = pArguments->GetLength(); |
1502 if (argc == 0) { | 1864 if (argc == 0) { |
1503 } else { | 1865 } else { |
1504 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); | 1866 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); |
1505 } | 1867 } |
1506 } | 1868 } |
| 1869 |
1507 void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, | 1870 void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, |
1508 FX_BOOL bSetting, | 1871 FX_BOOL bSetting, |
1509 XFA_ATTRIBUTE eAttribute) {} | 1872 XFA_ATTRIBUTE eAttribute) {} |
| 1873 |
1510 void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue, | 1874 void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue, |
1511 FX_BOOL bSetting, | 1875 FX_BOOL bSetting, |
1512 XFA_ATTRIBUTE eAttribute) {} | 1876 XFA_ATTRIBUTE eAttribute) {} |
| 1877 |
1513 void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue, | 1878 void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue, |
1514 FX_BOOL bSetting, | 1879 FX_BOOL bSetting, |
1515 XFA_ATTRIBUTE eAttribute) {} | 1880 XFA_ATTRIBUTE eAttribute) {} |
| 1881 |
1516 void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, | 1882 void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, |
1517 FX_BOOL bSetting, | 1883 FX_BOOL bSetting, |
1518 XFA_SOM_MESSAGETYPE iMessageType) { | 1884 XFA_SOM_MESSAGETYPE iMessageType) { |
1519 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1885 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1520 if (!pWidgetData) { | 1886 if (!pWidgetData) { |
1521 return; | 1887 return; |
1522 } | 1888 } |
1523 FX_BOOL bNew = FALSE; | 1889 FX_BOOL bNew = FALSE; |
1524 CXFA_Validate validate = pWidgetData->GetValidate(); | 1890 CXFA_Validate validate = pWidgetData->GetValidate(); |
1525 if (!validate) { | 1891 if (!validate) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 break; | 1924 break; |
1559 case XFA_SOM_MandatoryMessage: | 1925 case XFA_SOM_MandatoryMessage: |
1560 validate.GetNullMessageText(wsMessage); | 1926 validate.GetNullMessageText(wsMessage); |
1561 break; | 1927 break; |
1562 default: | 1928 default: |
1563 break; | 1929 break; |
1564 } | 1930 } |
1565 pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC()); | 1931 pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC()); |
1566 } | 1932 } |
1567 } | 1933 } |
| 1934 |
1568 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, | 1935 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, |
1569 FX_BOOL bSetting, | 1936 FX_BOOL bSetting, |
1570 XFA_ATTRIBUTE eAttribute) { | 1937 XFA_ATTRIBUTE eAttribute) { |
1571 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage); | 1938 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage); |
1572 } | 1939 } |
| 1940 |
1573 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, | 1941 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, |
1574 FX_BOOL bSetting, | 1942 FX_BOOL bSetting, |
1575 XFA_ATTRIBUTE eAttribute) { | 1943 XFA_ATTRIBUTE eAttribute) { |
1576 if (bSetting) { | 1944 if (bSetting) { |
1577 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1945 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1578 } else { | 1946 } else { |
1579 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1947 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1580 if (!pWidgetData) { | 1948 if (!pWidgetData) { |
1581 pValue->SetInteger(0); | 1949 pValue->SetInteger(0); |
1582 return; | 1950 return; |
1583 } | 1951 } |
1584 pValue->SetInteger(pWidgetData->CountChoiceListItems(TRUE)); | 1952 pValue->SetInteger(pWidgetData->CountChoiceListItems(TRUE)); |
1585 } | 1953 } |
1586 } | 1954 } |
| 1955 |
1587 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, | 1956 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, |
1588 FX_BOOL bSetting, | 1957 FX_BOOL bSetting, |
1589 XFA_ATTRIBUTE eAttribute) { | 1958 XFA_ATTRIBUTE eAttribute) { |
1590 XFA_Element eType = GetElementType(); | 1959 XFA_Element eType = GetElementType(); |
1591 if (eType == XFA_Element::Field) { | 1960 if (eType == XFA_Element::Field) { |
1592 Script_Field_DefaultValue(pValue, bSetting, eAttribute); | 1961 Script_Field_DefaultValue(pValue, bSetting, eAttribute); |
1593 return; | 1962 return; |
1594 } | 1963 } |
1595 if (eType == XFA_Element::Draw) { | 1964 if (eType == XFA_Element::Draw) { |
1596 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); | 1965 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 pValue->SetInteger(FXSYS_wtoi(content.c_str())); | 2011 pValue->SetInteger(FXSYS_wtoi(content.c_str())); |
1643 } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) { | 2012 } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) { |
1644 CFX_Decimal decimal(content.AsStringC()); | 2013 CFX_Decimal decimal(content.AsStringC()); |
1645 pValue->SetFloat((FX_FLOAT)(double)decimal); | 2014 pValue->SetFloat((FX_FLOAT)(double)decimal); |
1646 } else { | 2015 } else { |
1647 pValue->SetString( | 2016 pValue->SetString( |
1648 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 2017 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1649 } | 2018 } |
1650 } | 2019 } |
1651 } | 2020 } |
| 2021 |
1652 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, | 2022 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, |
1653 FX_BOOL bSetting, | 2023 FX_BOOL bSetting, |
1654 XFA_ATTRIBUTE eAttribute) { | 2024 XFA_ATTRIBUTE eAttribute) { |
1655 if (bSetting) { | 2025 if (bSetting) { |
1656 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2026 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1657 return; | 2027 return; |
1658 } | 2028 } |
1659 CFX_WideString content = GetScriptContent(TRUE); | 2029 CFX_WideString content = GetScriptContent(TRUE); |
1660 if (content.IsEmpty()) { | 2030 if (content.IsEmpty()) { |
1661 pValue->SetNull(); | 2031 pValue->SetNull(); |
1662 } else { | 2032 } else { |
1663 pValue->SetString( | 2033 pValue->SetString( |
1664 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 2034 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1665 } | 2035 } |
1666 } | 2036 } |
| 2037 |
1667 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, | 2038 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, |
1668 FX_BOOL bSetting, | 2039 FX_BOOL bSetting, |
1669 XFA_ATTRIBUTE eAttribute) { | 2040 XFA_ATTRIBUTE eAttribute) { |
1670 if (bSetting) { | 2041 if (bSetting) { |
1671 CFX_ByteString newValue; | 2042 CFX_ByteString newValue; |
1672 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined()))) | 2043 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined()))) |
1673 newValue = pValue->ToString(); | 2044 newValue = pValue->ToString(); |
1674 | 2045 |
1675 int32_t iValue = FXSYS_atoi(newValue.c_str()); | 2046 int32_t iValue = FXSYS_atoi(newValue.c_str()); |
1676 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); | 2047 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); |
1677 CFX_WideString wsFormatValue(wsNewValue); | 2048 CFX_WideString wsFormatValue(wsNewValue); |
1678 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); | 2049 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); |
1679 if (pContainerWidgetData) { | 2050 if (pContainerWidgetData) { |
1680 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); | 2051 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); |
1681 } | 2052 } |
1682 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 2053 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
1683 } else { | 2054 } else { |
1684 CFX_WideString wsValue = GetScriptContent(TRUE); | 2055 CFX_WideString wsValue = GetScriptContent(TRUE); |
1685 pValue->SetBoolean(wsValue == FX_WSTRC(L"1")); | 2056 pValue->SetBoolean(wsValue == FX_WSTRC(L"1")); |
1686 } | 2057 } |
1687 } | 2058 } |
1688 struct XFA_ExecEventParaInfo { | |
1689 public: | |
1690 uint32_t m_uHash; | |
1691 const FX_WCHAR* m_lpcEventName; | |
1692 XFA_EVENTTYPE m_eventType; | |
1693 uint32_t m_validFlags; | |
1694 }; | |
1695 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { | |
1696 {0x02a6c55a, L"postSubmit", XFA_EVENT_PostSubmit, 0}, | |
1697 {0x0ab466bb, L"preSubmit", XFA_EVENT_PreSubmit, 0}, | |
1698 {0x109d7ce7, L"mouseEnter", XFA_EVENT_MouseEnter, 5}, | |
1699 {0x17fad373, L"postPrint", XFA_EVENT_PostPrint, 0}, | |
1700 {0x1bfc72d9, L"preOpen", XFA_EVENT_PreOpen, 7}, | |
1701 {0x2196a452, L"initialize", XFA_EVENT_Initialize, 1}, | |
1702 {0x27410f03, L"mouseExit", XFA_EVENT_MouseExit, 5}, | |
1703 {0x33c43dec, L"docClose", XFA_EVENT_DocClose, 0}, | |
1704 {0x361fa1b6, L"preSave", XFA_EVENT_PreSave, 0}, | |
1705 {0x36f1c6d8, L"preSign", XFA_EVENT_PreSign, 6}, | |
1706 {0x4731d6ba, L"exit", XFA_EVENT_Exit, 2}, | |
1707 {0x56bf456b, L"docReady", XFA_EVENT_DocReady, 0}, | |
1708 {0x7233018a, L"validate", XFA_EVENT_Validate, 1}, | |
1709 {0x8808385e, L"indexChange", XFA_EVENT_IndexChange, 3}, | |
1710 {0x891f4606, L"change", XFA_EVENT_Change, 4}, | |
1711 {0x9528a7b4, L"prePrint", XFA_EVENT_PrePrint, 0}, | |
1712 {0x9f693b21, L"mouseDown", XFA_EVENT_MouseDown, 5}, | |
1713 {0xcdce56b3, L"full", XFA_EVENT_Full, 4}, | |
1714 {0xd576d08e, L"mouseUp", XFA_EVENT_MouseUp, 5}, | |
1715 {0xd95657a6, L"click", XFA_EVENT_Click, 4}, | |
1716 {0xdbfbe02e, L"calculate", XFA_EVENT_Calculate, 1}, | |
1717 {0xe25fa7b8, L"postOpen", XFA_EVENT_PostOpen, 7}, | |
1718 {0xe28dce7e, L"enter", XFA_EVENT_Enter, 2}, | |
1719 {0xfc82d695, L"postSave", XFA_EVENT_PostSave, 0}, | |
1720 {0xfd54fbb7, L"postSign", XFA_EVENT_PostSign, 6}, | |
1721 }; | |
1722 const XFA_ExecEventParaInfo* GetEventParaInfoByName( | |
1723 const CFX_WideStringC& wsEventName) { | |
1724 uint32_t uHash = FX_HashCode_GetW(wsEventName, false); | |
1725 int32_t iStart = 0; | |
1726 int32_t iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1; | |
1727 do { | |
1728 int32_t iMid = (iStart + iEnd) / 2; | |
1729 const XFA_ExecEventParaInfo* eventParaInfo = &gs_eventParaInfos[iMid]; | |
1730 if (uHash == eventParaInfo->m_uHash) { | |
1731 return eventParaInfo; | |
1732 } | |
1733 if (uHash < eventParaInfo->m_uHash) { | |
1734 iEnd = iMid - 1; | |
1735 } else { | |
1736 iStart = iMid + 1; | |
1737 } | |
1738 } while (iStart <= iEnd); | |
1739 return nullptr; | |
1740 } | |
1741 void XFA_STRING_TO_RGB(const CFX_WideString& strRGB, | |
1742 int32_t& r, | |
1743 int32_t& g, | |
1744 int32_t& b) { | |
1745 r = 0; | |
1746 g = 0; | |
1747 b = 0; | |
1748 | 2059 |
1749 FX_WCHAR zero = '0'; | |
1750 int32_t iIndex = 0; | |
1751 int32_t iLen = strRGB.GetLength(); | |
1752 for (int32_t i = 0; i < iLen; ++i) { | |
1753 FX_WCHAR ch = strRGB.GetAt(i); | |
1754 if (ch == L',') { | |
1755 ++iIndex; | |
1756 } | |
1757 if (iIndex > 2) { | |
1758 break; | |
1759 } | |
1760 int32_t iValue = ch - zero; | |
1761 if (iValue >= 0 && iValue <= 9) { | |
1762 switch (iIndex) { | |
1763 case 0: | |
1764 r = r * 10 + iValue; | |
1765 break; | |
1766 case 1: | |
1767 g = g * 10 + iValue; | |
1768 break; | |
1769 default: | |
1770 b = b * 10 + iValue; | |
1771 break; | |
1772 } | |
1773 } | |
1774 } | |
1775 } | |
1776 void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, | 2060 void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, |
1777 FX_BOOL bSetting, | 2061 FX_BOOL bSetting, |
1778 XFA_ATTRIBUTE eAttribute) { | 2062 XFA_ATTRIBUTE eAttribute) { |
1779 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2063 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1780 if (!pWidgetData) { | 2064 if (!pWidgetData) { |
1781 return; | 2065 return; |
1782 } | 2066 } |
1783 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 2067 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1784 int32_t iSize = border.CountEdges(); | 2068 int32_t iSize = border.CountEdges(); |
1785 if (bSetting) { | 2069 if (bSetting) { |
1786 int32_t r = 0; | 2070 int32_t r = 0; |
1787 int32_t g = 0; | 2071 int32_t g = 0; |
1788 int32_t b = 0; | 2072 int32_t b = 0; |
1789 XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b); | 2073 StrToRGB(pValue->ToWideString(), r, g, b); |
1790 FX_ARGB rgb = ArgbEncode(100, r, g, b); | 2074 FX_ARGB rgb = ArgbEncode(100, r, g, b); |
1791 for (int32_t i = 0; i < iSize; ++i) { | 2075 for (int32_t i = 0; i < iSize; ++i) { |
1792 CXFA_Edge edge = border.GetEdge(i); | 2076 CXFA_Edge edge = border.GetEdge(i); |
1793 edge.SetColor(rgb); | 2077 edge.SetColor(rgb); |
1794 } | 2078 } |
1795 } else { | 2079 } else { |
1796 CXFA_Edge edge = border.GetEdge(0); | 2080 CXFA_Edge edge = border.GetEdge(0); |
1797 FX_ARGB color = edge.GetColor(); | 2081 FX_ARGB color = edge.GetColor(); |
1798 int32_t a, r, g, b; | 2082 int32_t a, r, g, b; |
1799 ArgbDecode(color, a, r, g, b); | 2083 ArgbDecode(color, a, r, g, b); |
1800 CFX_WideString strColor; | 2084 CFX_WideString strColor; |
1801 strColor.Format(L"%d,%d,%d", r, g, b); | 2085 strColor.Format(L"%d,%d,%d", r, g, b); |
1802 pValue->SetString(FX_UTF8Encode(strColor).AsStringC()); | 2086 pValue->SetString(FX_UTF8Encode(strColor).AsStringC()); |
1803 } | 2087 } |
1804 } | 2088 } |
| 2089 |
1805 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, | 2090 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, |
1806 FX_BOOL bSetting, | 2091 FX_BOOL bSetting, |
1807 XFA_ATTRIBUTE eAttribute) { | 2092 XFA_ATTRIBUTE eAttribute) { |
1808 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2093 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1809 if (!pWidgetData) { | 2094 if (!pWidgetData) { |
1810 return; | 2095 return; |
1811 } | 2096 } |
1812 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 2097 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1813 int32_t iSize = border.CountEdges(); | 2098 int32_t iSize = border.CountEdges(); |
1814 CFX_WideString wsThickness; | 2099 CFX_WideString wsThickness; |
1815 if (bSetting) { | 2100 if (bSetting) { |
1816 wsThickness = pValue->ToWideString(); | 2101 wsThickness = pValue->ToWideString(); |
1817 for (int32_t i = 0; i < iSize; ++i) { | 2102 for (int32_t i = 0; i < iSize; ++i) { |
1818 CXFA_Edge edge = border.GetEdge(i); | 2103 CXFA_Edge edge = border.GetEdge(i); |
1819 CXFA_Measurement thickness(wsThickness.AsStringC()); | 2104 CXFA_Measurement thickness(wsThickness.AsStringC()); |
1820 edge.SetMSThickness(thickness); | 2105 edge.SetMSThickness(thickness); |
1821 } | 2106 } |
1822 } else { | 2107 } else { |
1823 CXFA_Edge edge = border.GetEdge(0); | 2108 CXFA_Edge edge = border.GetEdge(0); |
1824 CXFA_Measurement thickness = edge.GetMSThickness(); | 2109 CXFA_Measurement thickness = edge.GetMSThickness(); |
1825 thickness.ToString(wsThickness); | 2110 thickness.ToString(wsThickness); |
1826 pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC()); | 2111 pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC()); |
1827 } | 2112 } |
1828 } | 2113 } |
| 2114 |
1829 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, | 2115 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, |
1830 FX_BOOL bSetting, | 2116 FX_BOOL bSetting, |
1831 XFA_ATTRIBUTE eAttribute) { | 2117 XFA_ATTRIBUTE eAttribute) { |
1832 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2118 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1833 if (!pWidgetData) { | 2119 if (!pWidgetData) { |
1834 return; | 2120 return; |
1835 } | 2121 } |
1836 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 2122 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1837 CXFA_Fill borderfill = border.GetFill(TRUE); | 2123 CXFA_Fill borderfill = border.GetFill(TRUE); |
1838 CXFA_Node* pNode = borderfill.GetNode(); | 2124 CXFA_Node* pNode = borderfill.GetNode(); |
1839 if (!pNode) { | 2125 if (!pNode) { |
1840 return; | 2126 return; |
1841 } | 2127 } |
1842 if (bSetting) { | 2128 if (bSetting) { |
1843 int32_t r; | 2129 int32_t r; |
1844 int32_t g; | 2130 int32_t g; |
1845 int32_t b; | 2131 int32_t b; |
1846 XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b); | 2132 StrToRGB(pValue->ToWideString(), r, g, b); |
1847 FX_ARGB color = ArgbEncode(0xff, r, g, b); | 2133 FX_ARGB color = ArgbEncode(0xff, r, g, b); |
1848 borderfill.SetColor(color); | 2134 borderfill.SetColor(color); |
1849 } else { | 2135 } else { |
1850 FX_ARGB color = borderfill.GetColor(); | 2136 FX_ARGB color = borderfill.GetColor(); |
1851 int32_t a; | 2137 int32_t a; |
1852 int32_t r; | 2138 int32_t r; |
1853 int32_t g; | 2139 int32_t g; |
1854 int32_t b; | 2140 int32_t b; |
1855 ArgbDecode(color, a, r, g, b); | 2141 ArgbDecode(color, a, r, g, b); |
1856 CFX_WideString wsColor; | 2142 CFX_WideString wsColor; |
1857 wsColor.Format(L"%d,%d,%d", r, g, b); | 2143 wsColor.Format(L"%d,%d,%d", r, g, b); |
1858 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); | 2144 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); |
1859 } | 2145 } |
1860 } | 2146 } |
| 2147 |
1861 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, | 2148 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, |
1862 FX_BOOL bSetting, | 2149 FX_BOOL bSetting, |
1863 XFA_ATTRIBUTE eAttribute) { | 2150 XFA_ATTRIBUTE eAttribute) { |
1864 if (!bSetting) { | 2151 if (!bSetting) { |
1865 CXFA_Node* pDataNode = GetBindData(); | 2152 CXFA_Node* pDataNode = GetBindData(); |
1866 if (pDataNode) { | 2153 if (pDataNode) { |
1867 pValue->Assign( | 2154 pValue->Assign( |
1868 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); | 2155 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); |
1869 } else { | 2156 } else { |
1870 pValue->SetNull(); | 2157 pValue->SetNull(); |
1871 } | 2158 } |
1872 } else { | 2159 } else { |
1873 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2160 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1874 } | 2161 } |
1875 } | 2162 } |
| 2163 |
1876 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, | 2164 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, |
1877 FX_BOOL bSetting, | 2165 FX_BOOL bSetting, |
1878 XFA_ATTRIBUTE eAttribute) { | 2166 XFA_ATTRIBUTE eAttribute) { |
1879 if (bSetting) { | 2167 if (bSetting) { |
1880 if (pValue && pValue->IsString()) { | 2168 if (pValue && pValue->IsString()) { |
1881 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2169 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1882 ASSERT(pWidgetData); | 2170 ASSERT(pWidgetData); |
1883 XFA_Element uiType = pWidgetData->GetUIType(); | 2171 XFA_Element uiType = pWidgetData->GetUIType(); |
1884 if (uiType == XFA_Element::Text) { | 2172 if (uiType == XFA_Element::Text) { |
1885 CFX_WideString wsNewValue = pValue->ToWideString(); | 2173 CFX_WideString wsNewValue = pValue->ToWideString(); |
1886 CFX_WideString wsFormatValue(wsNewValue); | 2174 CFX_WideString wsFormatValue(wsNewValue); |
1887 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 2175 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
1888 } | 2176 } |
1889 } | 2177 } |
1890 } else { | 2178 } else { |
1891 CFX_WideString content = GetScriptContent(TRUE); | 2179 CFX_WideString content = GetScriptContent(TRUE); |
1892 if (content.IsEmpty()) { | 2180 if (content.IsEmpty()) { |
1893 pValue->SetNull(); | 2181 pValue->SetNull(); |
1894 } else { | 2182 } else { |
1895 pValue->SetString( | 2183 pValue->SetString( |
1896 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 2184 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1897 } | 2185 } |
1898 } | 2186 } |
1899 } | 2187 } |
| 2188 |
1900 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, | 2189 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, |
1901 FX_BOOL bSetting, | 2190 FX_BOOL bSetting, |
1902 XFA_ATTRIBUTE eAttribute) { | 2191 XFA_ATTRIBUTE eAttribute) { |
1903 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2192 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1904 if (!pWidgetData) { | 2193 if (!pWidgetData) { |
1905 return; | 2194 return; |
1906 } | 2195 } |
1907 if (bSetting) { | 2196 if (bSetting) { |
1908 if (pValue && pValue->IsNull()) { | 2197 if (pValue && pValue->IsNull()) { |
1909 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; | 2198 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 } else if (pNode && pNode->GetElementType() == XFA_Element::Float) { | 2244 } else if (pNode && pNode->GetElementType() == XFA_Element::Float) { |
1956 CFX_Decimal decimal(content.AsStringC()); | 2245 CFX_Decimal decimal(content.AsStringC()); |
1957 pValue->SetFloat((FX_FLOAT)(double)decimal); | 2246 pValue->SetFloat((FX_FLOAT)(double)decimal); |
1958 } else { | 2247 } else { |
1959 pValue->SetString( | 2248 pValue->SetString( |
1960 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 2249 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1961 } | 2250 } |
1962 } | 2251 } |
1963 } | 2252 } |
1964 } | 2253 } |
| 2254 |
1965 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, | 2255 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, |
1966 FX_BOOL bSetting, | 2256 FX_BOOL bSetting, |
1967 XFA_ATTRIBUTE eAttribute) { | 2257 XFA_ATTRIBUTE eAttribute) { |
1968 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2258 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1969 if (!pWidgetData) { | 2259 if (!pWidgetData) { |
1970 return; | 2260 return; |
1971 } | 2261 } |
1972 if (bSetting) { | 2262 if (bSetting) { |
1973 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit); | 2263 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit); |
1974 } else { | 2264 } else { |
1975 CFX_WideString wsValue; | 2265 CFX_WideString wsValue; |
1976 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); | 2266 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); |
1977 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 2267 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
1978 } | 2268 } |
1979 } | 2269 } |
| 2270 |
1980 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, | 2271 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, |
1981 FX_BOOL bSetting, | 2272 FX_BOOL bSetting, |
1982 XFA_ATTRIBUTE eAttribute) { | 2273 XFA_ATTRIBUTE eAttribute) { |
1983 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2274 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1984 if (!pWidgetData) { | 2275 if (!pWidgetData) { |
1985 return; | 2276 return; |
1986 } | 2277 } |
1987 CXFA_Font font = pWidgetData->GetFont(TRUE); | 2278 CXFA_Font font = pWidgetData->GetFont(TRUE); |
1988 CXFA_Node* pNode = font.GetNode(); | 2279 CXFA_Node* pNode = font.GetNode(); |
1989 if (!pNode) { | 2280 if (!pNode) { |
1990 return; | 2281 return; |
1991 } | 2282 } |
1992 if (bSetting) { | 2283 if (bSetting) { |
1993 int32_t r; | 2284 int32_t r; |
1994 int32_t g; | 2285 int32_t g; |
1995 int32_t b; | 2286 int32_t b; |
1996 XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b); | 2287 StrToRGB(pValue->ToWideString(), r, g, b); |
1997 FX_ARGB color = ArgbEncode(0xff, r, g, b); | 2288 FX_ARGB color = ArgbEncode(0xff, r, g, b); |
1998 font.SetColor(color); | 2289 font.SetColor(color); |
1999 } else { | 2290 } else { |
2000 FX_ARGB color = font.GetColor(); | 2291 FX_ARGB color = font.GetColor(); |
2001 int32_t a; | 2292 int32_t a; |
2002 int32_t r; | 2293 int32_t r; |
2003 int32_t g; | 2294 int32_t g; |
2004 int32_t b; | 2295 int32_t b; |
2005 ArgbDecode(color, a, r, g, b); | 2296 ArgbDecode(color, a, r, g, b); |
2006 CFX_WideString wsColor; | 2297 CFX_WideString wsColor; |
2007 wsColor.Format(L"%d,%d,%d", r, g, b); | 2298 wsColor.Format(L"%d,%d,%d", r, g, b); |
2008 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); | 2299 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); |
2009 } | 2300 } |
2010 } | 2301 } |
| 2302 |
2011 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, | 2303 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, |
2012 FX_BOOL bSetting, | 2304 FX_BOOL bSetting, |
2013 XFA_ATTRIBUTE eAttribute) { | 2305 XFA_ATTRIBUTE eAttribute) { |
2014 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage); | 2306 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage); |
2015 } | 2307 } |
| 2308 |
2016 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, | 2309 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, |
2017 FX_BOOL bSetting, | 2310 FX_BOOL bSetting, |
2018 XFA_ATTRIBUTE eAttribute) { | 2311 XFA_ATTRIBUTE eAttribute) { |
2019 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2312 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2020 if (!pWidgetData) { | 2313 if (!pWidgetData) { |
2021 return; | 2314 return; |
2022 } | 2315 } |
2023 if (bSetting) { | 2316 if (bSetting) { |
2024 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display); | 2317 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display); |
2025 } else { | 2318 } else { |
2026 CFX_WideString wsValue; | 2319 CFX_WideString wsValue; |
2027 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 2320 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
2028 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 2321 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2029 } | 2322 } |
2030 } | 2323 } |
| 2324 |
2031 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, | 2325 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, |
2032 FX_BOOL bSetting, | 2326 FX_BOOL bSetting, |
2033 XFA_ATTRIBUTE eAttribute) { | 2327 XFA_ATTRIBUTE eAttribute) { |
2034 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2328 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2035 if (!pWidgetData) { | 2329 if (!pWidgetData) { |
2036 return; | 2330 return; |
2037 } | 2331 } |
2038 CXFA_Validate validate = pWidgetData->GetValidate(TRUE); | 2332 CXFA_Validate validate = pWidgetData->GetValidate(TRUE); |
2039 if (bSetting) { | 2333 if (bSetting) { |
2040 validate.SetNullTest(pValue->ToWideString()); | 2334 validate.SetNullTest(pValue->ToWideString()); |
2041 } else { | 2335 } else { |
2042 int32_t iValue = validate.GetNullTest(); | 2336 int32_t iValue = validate.GetNullTest(); |
2043 const XFA_ATTRIBUTEENUMINFO* pInfo = | 2337 const XFA_ATTRIBUTEENUMINFO* pInfo = |
2044 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); | 2338 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); |
2045 CFX_WideString wsValue; | 2339 CFX_WideString wsValue; |
2046 if (pInfo) | 2340 if (pInfo) |
2047 wsValue = pInfo->pName; | 2341 wsValue = pInfo->pName; |
2048 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 2342 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2049 } | 2343 } |
2050 } | 2344 } |
| 2345 |
2051 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, | 2346 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, |
2052 FX_BOOL bSetting, | 2347 FX_BOOL bSetting, |
2053 XFA_ATTRIBUTE eAttribute) { | 2348 XFA_ATTRIBUTE eAttribute) { |
2054 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage); | 2349 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage); |
2055 } | 2350 } |
| 2351 |
2056 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, | 2352 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, |
2057 FX_BOOL bSetting, | 2353 FX_BOOL bSetting, |
2058 XFA_ATTRIBUTE eAttribute) { | 2354 XFA_ATTRIBUTE eAttribute) { |
2059 if (bSetting) { | 2355 if (bSetting) { |
2060 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2356 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2061 } else { | 2357 } else { |
2062 pValue->SetNull(); | 2358 pValue->SetNull(); |
2063 } | 2359 } |
2064 } | 2360 } |
| 2361 |
2065 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, | 2362 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, |
2066 FX_BOOL bSetting, | 2363 FX_BOOL bSetting, |
2067 XFA_ATTRIBUTE eAttribute) { | 2364 XFA_ATTRIBUTE eAttribute) { |
2068 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2365 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2069 if (!pWidgetData) { | 2366 if (!pWidgetData) { |
2070 return; | 2367 return; |
2071 } | 2368 } |
2072 if (bSetting) { | 2369 if (bSetting) { |
2073 int32_t iIndex = pValue->ToInteger(); | 2370 int32_t iIndex = pValue->ToInteger(); |
2074 if (iIndex == -1) { | 2371 if (iIndex == -1) { |
2075 pWidgetData->ClearAllSelections(); | 2372 pWidgetData->ClearAllSelections(); |
2076 return; | 2373 return; |
2077 } | 2374 } |
2078 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); | 2375 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); |
2079 } else { | 2376 } else { |
2080 pValue->SetInteger(pWidgetData->GetSelectedItem()); | 2377 pValue->SetInteger(pWidgetData->GetSelectedItem()); |
2081 } | 2378 } |
2082 } | 2379 } |
| 2380 |
2083 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { | 2381 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { |
2084 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2382 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2085 if (!pWidgetData) { | 2383 if (!pWidgetData) { |
2086 return; | 2384 return; |
2087 } | 2385 } |
2088 pWidgetData->DeleteItem(-1, TRUE); | 2386 pWidgetData->DeleteItem(-1, TRUE); |
2089 } | 2387 } |
| 2388 |
2090 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { | 2389 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { |
2091 int32_t argc = pArguments->GetLength(); | 2390 int32_t argc = pArguments->GetLength(); |
2092 if (argc == 1) { | 2391 if (argc == 1) { |
2093 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2392 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2094 int32_t iRet = execSingleEventByName( | 2393 int32_t iRet = execSingleEventByName( |
2095 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2394 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2096 XFA_Element::Field); | 2395 XFA_Element::Field); |
2097 if (eventString == "validate") { | 2396 if (eventString == "validate") { |
2098 pArguments->GetReturnValue()->SetBoolean( | 2397 pArguments->GetReturnValue()->SetBoolean( |
2099 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); | 2398 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2100 } | 2399 } |
2101 } else { | 2400 } else { |
2102 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); | 2401 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); |
2103 } | 2402 } |
2104 } | 2403 } |
| 2404 |
2105 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2405 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2106 int32_t argc = pArguments->GetLength(); | 2406 int32_t argc = pArguments->GetLength(); |
2107 if (argc == 0) { | 2407 if (argc == 0) { |
2108 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2408 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2109 if (!pNotify) { | 2409 if (!pNotify) { |
2110 return; | 2410 return; |
2111 } | 2411 } |
2112 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); | 2412 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); |
2113 } else { | 2413 } else { |
2114 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 2414 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
2115 } | 2415 } |
2116 } | 2416 } |
| 2417 |
2117 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { | 2418 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { |
2118 int32_t iLength = pArguments->GetLength(); | 2419 int32_t iLength = pArguments->GetLength(); |
2119 if (iLength != 1) { | 2420 if (iLength != 1) { |
2120 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); | 2421 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); |
2121 return; | 2422 return; |
2122 } | 2423 } |
2123 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2424 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2124 if (!pWidgetData) { | 2425 if (!pWidgetData) { |
2125 return; | 2426 return; |
2126 } | 2427 } |
2127 int32_t iIndex = pArguments->GetInt32(0); | 2428 int32_t iIndex = pArguments->GetInt32(0); |
2128 FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); | 2429 FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); |
2129 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2430 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2130 if (pValue) | 2431 if (pValue) |
2131 pValue->SetBoolean(bValue); | 2432 pValue->SetBoolean(bValue); |
2132 } | 2433 } |
| 2434 |
2133 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { | 2435 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { |
2134 int32_t iLength = pArguments->GetLength(); | 2436 int32_t iLength = pArguments->GetLength(); |
2135 if (iLength != 1) { | 2437 if (iLength != 1) { |
2136 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); | 2438 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); |
2137 return; | 2439 return; |
2138 } | 2440 } |
2139 int32_t iIndex = pArguments->GetInt32(0); | 2441 int32_t iIndex = pArguments->GetInt32(0); |
2140 if (iIndex < 0) { | 2442 if (iIndex < 0) { |
2141 pArguments->GetReturnValue()->SetNull(); | 2443 pArguments->GetReturnValue()->SetNull(); |
2142 return; | 2444 return; |
2143 } | 2445 } |
2144 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2446 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2145 if (!pWidgetData) { | 2447 if (!pWidgetData) { |
2146 pArguments->GetReturnValue()->SetNull(); | 2448 pArguments->GetReturnValue()->SetNull(); |
2147 return; | 2449 return; |
2148 } | 2450 } |
2149 CFX_WideString wsValue; | 2451 CFX_WideString wsValue; |
2150 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); | 2452 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); |
2151 if (bHasItem) { | 2453 if (bHasItem) { |
2152 pArguments->GetReturnValue()->SetString( | 2454 pArguments->GetReturnValue()->SetString( |
2153 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 2455 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
2154 } else { | 2456 } else { |
2155 pArguments->GetReturnValue()->SetNull(); | 2457 pArguments->GetReturnValue()->SetNull(); |
2156 } | 2458 } |
2157 } | 2459 } |
| 2460 |
2158 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { | 2461 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { |
2159 int32_t iLength = pArguments->GetLength(); | 2462 int32_t iLength = pArguments->GetLength(); |
2160 if (iLength != 1) { | 2463 if (iLength != 1) { |
2161 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); | 2464 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); |
2162 return; | 2465 return; |
2163 } | 2466 } |
2164 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2467 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2165 if (!pWidgetData) { | 2468 if (!pWidgetData) { |
2166 return; | 2469 return; |
2167 } | 2470 } |
2168 CFX_ByteString bsValue = pArguments->GetUTF8String(0); | 2471 CFX_ByteString bsValue = pArguments->GetUTF8String(0); |
2169 CFX_WideString wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2472 CFX_WideString wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2170 CFX_WideString wsBoundValue; | 2473 CFX_WideString wsBoundValue; |
2171 pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue); | 2474 pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue); |
2172 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2475 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2173 if (pValue) | 2476 if (pValue) |
2174 pValue->SetString(FX_UTF8Encode(wsBoundValue).AsStringC()); | 2477 pValue->SetString(FX_UTF8Encode(wsBoundValue).AsStringC()); |
2175 } | 2478 } |
| 2479 |
2176 void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { | 2480 void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { |
2177 int32_t iLength = pArguments->GetLength(); | 2481 int32_t iLength = pArguments->GetLength(); |
2178 if (iLength != 1) { | 2482 if (iLength != 1) { |
2179 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState"); | 2483 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState"); |
2180 return; | 2484 return; |
2181 } | 2485 } |
2182 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2486 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2183 if (!pWidgetData) { | 2487 if (!pWidgetData) { |
2184 return; | 2488 return; |
2185 } | 2489 } |
2186 int32_t iIndex = pArguments->GetInt32(0); | 2490 int32_t iIndex = pArguments->GetInt32(0); |
2187 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); | 2491 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); |
2188 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2492 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2189 if (pValue) | 2493 if (pValue) |
2190 pValue->SetBoolean(bValue); | 2494 pValue->SetBoolean(bValue); |
2191 } | 2495 } |
| 2496 |
2192 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2497 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2193 int32_t argc = pArguments->GetLength(); | 2498 int32_t argc = pArguments->GetLength(); |
2194 if (argc == 0) { | 2499 if (argc == 0) { |
2195 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2500 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2196 if (!pNotify) { | 2501 if (!pNotify) { |
2197 return; | 2502 return; |
2198 } | 2503 } |
2199 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); | 2504 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); |
2200 } else { | 2505 } else { |
2201 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2506 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2202 } | 2507 } |
2203 } | 2508 } |
| 2509 |
2204 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} | 2510 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} |
| 2511 |
2205 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { | 2512 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { |
2206 int32_t iLength = pArguments->GetLength(); | 2513 int32_t iLength = pArguments->GetLength(); |
2207 if (iLength != 1) { | 2514 if (iLength != 1) { |
2208 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem"); | 2515 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem"); |
2209 return; | 2516 return; |
2210 } | 2517 } |
2211 int32_t iIndex = pArguments->GetInt32(0); | 2518 int32_t iIndex = pArguments->GetInt32(0); |
2212 if (iIndex < 0) { | 2519 if (iIndex < 0) { |
2213 pArguments->GetReturnValue()->SetNull(); | 2520 pArguments->GetReturnValue()->SetNull(); |
2214 return; | 2521 return; |
2215 } | 2522 } |
2216 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2523 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2217 if (!pWidgetData) { | 2524 if (!pWidgetData) { |
2218 pArguments->GetReturnValue()->SetNull(); | 2525 pArguments->GetReturnValue()->SetNull(); |
2219 return; | 2526 return; |
2220 } | 2527 } |
2221 CFX_WideString wsValue; | 2528 CFX_WideString wsValue; |
2222 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); | 2529 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); |
2223 if (bHasItem) { | 2530 if (bHasItem) { |
2224 pArguments->GetReturnValue()->SetString( | 2531 pArguments->GetReturnValue()->SetString( |
2225 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 2532 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
2226 } else { | 2533 } else { |
2227 pArguments->GetReturnValue()->SetNull(); | 2534 pArguments->GetReturnValue()->SetNull(); |
2228 } | 2535 } |
2229 } | 2536 } |
| 2537 |
2230 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { | 2538 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { |
2231 int32_t iLength = pArguments->GetLength(); | 2539 int32_t iLength = pArguments->GetLength(); |
2232 if (iLength != 2) { | 2540 if (iLength != 2) { |
2233 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState"); | 2541 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState"); |
2234 return; | 2542 return; |
2235 } | 2543 } |
2236 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2544 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2237 if (!pWidgetData) | 2545 if (!pWidgetData) |
2238 return; | 2546 return; |
2239 | 2547 |
2240 int32_t iIndex = pArguments->GetInt32(0); | 2548 int32_t iIndex = pArguments->GetInt32(0); |
2241 if (pArguments->GetInt32(1) != 0) { | 2549 if (pArguments->GetInt32(1) != 0) { |
2242 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); | 2550 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); |
2243 } else { | 2551 } else { |
2244 if (pWidgetData->GetItemState(iIndex)) | 2552 if (pWidgetData->GetItemState(iIndex)) |
2245 pWidgetData->SetItemState(iIndex, FALSE, true, TRUE, TRUE); | 2553 pWidgetData->SetItemState(iIndex, FALSE, true, TRUE, TRUE); |
2246 } | 2554 } |
2247 } | 2555 } |
| 2556 |
2248 void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { | 2557 void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { |
2249 int32_t iLength = pArguments->GetLength(); | 2558 int32_t iLength = pArguments->GetLength(); |
2250 if (iLength < 1 || iLength > 2) { | 2559 if (iLength < 1 || iLength > 2) { |
2251 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem"); | 2560 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem"); |
2252 return; | 2561 return; |
2253 } | 2562 } |
2254 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2563 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2255 if (!pWidgetData) { | 2564 if (!pWidgetData) { |
2256 return; | 2565 return; |
2257 } | 2566 } |
2258 CFX_WideString wsLabel; | 2567 CFX_WideString wsLabel; |
2259 CFX_WideString wsValue; | 2568 CFX_WideString wsValue; |
2260 if (iLength >= 1) { | 2569 if (iLength >= 1) { |
2261 CFX_ByteString bsLabel = pArguments->GetUTF8String(0); | 2570 CFX_ByteString bsLabel = pArguments->GetUTF8String(0); |
2262 wsLabel = CFX_WideString::FromUTF8(bsLabel.AsStringC()); | 2571 wsLabel = CFX_WideString::FromUTF8(bsLabel.AsStringC()); |
2263 } | 2572 } |
2264 if (iLength >= 2) { | 2573 if (iLength >= 2) { |
2265 CFX_ByteString bsValue = pArguments->GetUTF8String(1); | 2574 CFX_ByteString bsValue = pArguments->GetUTF8String(1); |
2266 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2575 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2267 } | 2576 } |
2268 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); | 2577 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); |
2269 } | 2578 } |
| 2579 |
2270 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { | 2580 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { |
2271 int32_t argc = pArguments->GetLength(); | 2581 int32_t argc = pArguments->GetLength(); |
2272 if (argc == 0) { | 2582 if (argc == 0) { |
2273 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2583 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2274 if (!pNotify) { | 2584 if (!pNotify) { |
2275 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2585 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2276 } else { | 2586 } else { |
2277 int32_t iRet = | 2587 int32_t iRet = |
2278 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); | 2588 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); |
2279 pArguments->GetReturnValue()->SetBoolean( | 2589 pArguments->GetReturnValue()->SetBoolean( |
2280 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); | 2590 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2281 } | 2591 } |
2282 } else { | 2592 } else { |
2283 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2593 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2284 } | 2594 } |
2285 } | 2595 } |
| 2596 |
2286 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, | 2597 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, |
2287 FX_BOOL bSetting, | 2598 FX_BOOL bSetting, |
2288 XFA_ATTRIBUTE eAttribute) { | 2599 XFA_ATTRIBUTE eAttribute) { |
2289 if (!bSetting) { | 2600 if (!bSetting) { |
2290 } else { | 2601 } else { |
2291 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2602 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2292 } | 2603 } |
2293 } | 2604 } |
| 2605 |
2294 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, | 2606 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, |
2295 FX_BOOL bSetting, | 2607 FX_BOOL bSetting, |
2296 XFA_ATTRIBUTE eAttribute) { | 2608 XFA_ATTRIBUTE eAttribute) { |
2297 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2609 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2298 if (!pWidgetData) { | 2610 if (!pWidgetData) { |
2299 return; | 2611 return; |
2300 } | 2612 } |
2301 if (bSetting) { | 2613 if (bSetting) { |
2302 pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringC(), | 2614 pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringC(), |
2303 true, TRUE, TRUE); | 2615 true, TRUE, TRUE); |
2304 } else { | 2616 } else { |
2305 CFX_WideString wsValue = GetScriptContent(TRUE); | 2617 CFX_WideString wsValue = GetScriptContent(TRUE); |
2306 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); | 2618 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); |
2307 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { | 2619 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { |
2308 pValue->SetNull(); | 2620 pValue->SetNull(); |
2309 } else { | 2621 } else { |
2310 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 2622 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2311 } | 2623 } |
2312 } | 2624 } |
2313 } | 2625 } |
| 2626 |
2314 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, | 2627 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, |
2315 FX_BOOL bSetting, | 2628 FX_BOOL bSetting, |
2316 XFA_ATTRIBUTE eAttribute) {} | 2629 XFA_ATTRIBUTE eAttribute) {} |
| 2630 |
2317 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { | 2631 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { |
2318 int32_t argc = pArguments->GetLength(); | 2632 int32_t argc = pArguments->GetLength(); |
2319 if (argc == 1) { | 2633 if (argc == 1) { |
2320 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2634 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2321 execSingleEventByName( | 2635 execSingleEventByName( |
2322 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2636 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2323 XFA_Element::ExclGroup); | 2637 XFA_Element::ExclGroup); |
2324 } else { | 2638 } else { |
2325 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); | 2639 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); |
2326 } | 2640 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 if (argc == 0) { | 2675 if (argc == 0) { |
2362 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2676 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2363 if (!pNotify) { | 2677 if (!pNotify) { |
2364 return; | 2678 return; |
2365 } | 2679 } |
2366 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); | 2680 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); |
2367 } else { | 2681 } else { |
2368 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 2682 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
2369 } | 2683 } |
2370 } | 2684 } |
| 2685 |
2371 void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2686 void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2372 int32_t argc = pArguments->GetLength(); | 2687 int32_t argc = pArguments->GetLength(); |
2373 if (argc == 0) { | 2688 if (argc == 0) { |
2374 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2689 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2375 if (!pNotify) { | 2690 if (!pNotify) { |
2376 return; | 2691 return; |
2377 } | 2692 } |
2378 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 2693 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
2379 } else { | 2694 } else { |
2380 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2695 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2381 } | 2696 } |
2382 } | 2697 } |
| 2698 |
2383 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { | 2699 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { |
2384 int32_t argc = pArguments->GetLength(); | 2700 int32_t argc = pArguments->GetLength(); |
2385 if (argc == 0) { | 2701 if (argc == 0) { |
2386 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2702 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2387 if (!pNotify) { | 2703 if (!pNotify) { |
2388 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2704 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2389 } else { | 2705 } else { |
2390 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 2706 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
2391 pArguments->GetReturnValue()->SetBoolean( | 2707 pArguments->GetReturnValue()->SetBoolean( |
2392 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); | 2708 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2393 } | 2709 } |
2394 } else { | 2710 } else { |
2395 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2711 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2396 } | 2712 } |
2397 } | 2713 } |
2398 static CXFA_Node* XFA_ScriptInstanceManager_GetItem(CXFA_Node* pInstMgrNode, | 2714 |
2399 int32_t iIndex) { | |
2400 ASSERT(pInstMgrNode); | |
2401 int32_t iCount = 0; | |
2402 uint32_t dwNameHash = 0; | |
2403 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
2404 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
2405 XFA_Element eCurType = pNode->GetElementType(); | |
2406 if (eCurType == XFA_Element::InstanceManager) { | |
2407 break; | |
2408 } | |
2409 if ((eCurType != XFA_Element::Subform) && | |
2410 (eCurType != XFA_Element::SubformSet)) { | |
2411 continue; | |
2412 } | |
2413 if (iCount == 0) { | |
2414 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); | |
2415 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); | |
2416 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || | |
2417 wsInstName.Mid(1) != wsName) { | |
2418 return nullptr; | |
2419 } | |
2420 dwNameHash = pNode->GetNameHash(); | |
2421 } | |
2422 if (dwNameHash != pNode->GetNameHash()) { | |
2423 break; | |
2424 } | |
2425 iCount++; | |
2426 if (iCount > iIndex) { | |
2427 return pNode; | |
2428 } | |
2429 } | |
2430 return nullptr; | |
2431 } | |
2432 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, | 2715 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, |
2433 FX_BOOL bSetting, | 2716 FX_BOOL bSetting, |
2434 XFA_ATTRIBUTE eAttribute) { | 2717 XFA_ATTRIBUTE eAttribute) { |
2435 if (bSetting) { | 2718 if (bSetting) { |
2436 int32_t iTo = pValue->ToInteger(); | 2719 int32_t iTo = pValue->ToInteger(); |
2437 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); | 2720 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); |
2438 CXFA_Node* pManagerNode = nullptr; | 2721 CXFA_Node* pManagerNode = nullptr; |
2439 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2722 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2440 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2723 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2441 if (pNode->GetElementType() == XFA_Element::InstanceManager) { | 2724 if (pNode->GetElementType() == XFA_Element::InstanceManager) { |
2442 pManagerNode = pNode; | 2725 pManagerNode = pNode; |
2443 break; | 2726 break; |
2444 } | 2727 } |
2445 } | 2728 } |
2446 if (pManagerNode) { | 2729 if (pManagerNode) { |
2447 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); | 2730 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); |
2448 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2731 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2449 if (!pNotify) { | 2732 if (!pNotify) { |
2450 return; | 2733 return; |
2451 } | 2734 } |
2452 CXFA_Node* pToInstance = | 2735 CXFA_Node* pToInstance = GetItem(pManagerNode, iTo); |
2453 XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); | |
2454 if (pToInstance && | 2736 if (pToInstance && |
2455 pToInstance->GetElementType() == XFA_Element::Subform) { | 2737 pToInstance->GetElementType() == XFA_Element::Subform) { |
2456 pNotify->RunSubformIndexChange(pToInstance); | 2738 pNotify->RunSubformIndexChange(pToInstance); |
2457 } | 2739 } |
2458 CXFA_Node* pFromInstance = | 2740 CXFA_Node* pFromInstance = GetItem(pManagerNode, iFrom); |
2459 XFA_ScriptInstanceManager_GetItem(pManagerNode, iFrom); | |
2460 if (pFromInstance && | 2741 if (pFromInstance && |
2461 pFromInstance->GetElementType() == XFA_Element::Subform) { | 2742 pFromInstance->GetElementType() == XFA_Element::Subform) { |
2462 pNotify->RunSubformIndexChange(pFromInstance); | 2743 pNotify->RunSubformIndexChange(pFromInstance); |
2463 } | 2744 } |
2464 } | 2745 } |
2465 } else { | 2746 } else { |
2466 pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); | 2747 pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); |
2467 } | 2748 } |
2468 } | 2749 } |
| 2750 |
2469 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, | 2751 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, |
2470 FX_BOOL bSetting, | 2752 FX_BOOL bSetting, |
2471 XFA_ATTRIBUTE eAttribute) { | 2753 XFA_ATTRIBUTE eAttribute) { |
2472 if (!bSetting) { | 2754 if (!bSetting) { |
2473 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); | 2755 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); |
2474 CXFA_Node* pInstanceMgr = nullptr; | 2756 CXFA_Node* pInstanceMgr = nullptr; |
2475 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2757 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2476 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2758 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2477 if (pNode->GetElementType() == XFA_Element::InstanceManager) { | 2759 if (pNode->GetElementType() == XFA_Element::InstanceManager) { |
2478 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); | 2760 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
2479 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && | 2761 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && |
2480 wsInstMgrName.Mid(1) == wsName) { | 2762 wsInstMgrName.Mid(1) == wsName) { |
2481 pInstanceMgr = pNode; | 2763 pInstanceMgr = pNode; |
2482 } | 2764 } |
2483 break; | 2765 break; |
2484 } | 2766 } |
2485 } | 2767 } |
2486 if (pInstanceMgr) { | 2768 if (pInstanceMgr) { |
2487 pValue->Assign( | 2769 pValue->Assign( |
2488 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); | 2770 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); |
2489 } else { | 2771 } else { |
2490 pValue->SetNull(); | 2772 pValue->SetNull(); |
2491 } | 2773 } |
2492 } else { | 2774 } else { |
2493 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2775 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2494 } | 2776 } |
2495 } | 2777 } |
| 2778 |
2496 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, | 2779 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, |
2497 FX_BOOL bSetting, | 2780 FX_BOOL bSetting, |
2498 XFA_ATTRIBUTE eAttribute) { | 2781 XFA_ATTRIBUTE eAttribute) { |
2499 if (bSetting) { | 2782 if (bSetting) { |
2500 SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, TRUE); | 2783 SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, TRUE); |
2501 } else { | 2784 } else { |
2502 CFX_WideString wsLocaleName; | 2785 CFX_WideString wsLocaleName; |
2503 GetLocaleName(wsLocaleName); | 2786 GetLocaleName(wsLocaleName); |
2504 pValue->SetString( | 2787 pValue->SetString( |
2505 FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) | 2788 FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) |
2506 .AsStringC()); | 2789 .AsStringC()); |
2507 } | 2790 } |
2508 } | 2791 } |
| 2792 |
2509 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { | 2793 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { |
2510 int32_t argc = pArguments->GetLength(); | 2794 int32_t argc = pArguments->GetLength(); |
2511 if (argc == 1) { | 2795 if (argc == 1) { |
2512 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2796 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2513 execSingleEventByName( | 2797 execSingleEventByName( |
2514 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2798 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2515 XFA_Element::Subform); | 2799 XFA_Element::Subform); |
2516 } else { | 2800 } else { |
2517 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); | 2801 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); |
2518 } | 2802 } |
2519 } | 2803 } |
| 2804 |
2520 void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2805 void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2521 int32_t argc = pArguments->GetLength(); | 2806 int32_t argc = pArguments->GetLength(); |
2522 if (argc == 0) { | 2807 if (argc == 0) { |
2523 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2808 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2524 if (!pNotify) { | 2809 if (!pNotify) { |
2525 return; | 2810 return; |
2526 } | 2811 } |
2527 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); | 2812 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); |
2528 } else { | 2813 } else { |
2529 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 2814 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
2530 } | 2815 } |
2531 } | 2816 } |
| 2817 |
2532 void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2818 void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2533 int32_t argc = pArguments->GetLength(); | 2819 int32_t argc = pArguments->GetLength(); |
2534 if (argc == 0) { | 2820 if (argc == 0) { |
2535 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2821 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2536 if (!pNotify) { | 2822 if (!pNotify) { |
2537 return; | 2823 return; |
2538 } | 2824 } |
2539 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 2825 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
2540 } else { | 2826 } else { |
2541 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2827 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2542 } | 2828 } |
2543 } | 2829 } |
| 2830 |
2544 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { | 2831 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { |
2545 int32_t argc = pArguments->GetLength(); | 2832 int32_t argc = pArguments->GetLength(); |
2546 if (argc == 0) { | 2833 if (argc == 0) { |
2547 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 2834 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
2548 if (!pNotify) { | 2835 if (!pNotify) { |
2549 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2836 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2550 } else { | 2837 } else { |
2551 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 2838 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
2552 pArguments->GetReturnValue()->SetBoolean( | 2839 pArguments->GetReturnValue()->SetBoolean( |
2553 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); | 2840 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2554 } | 2841 } |
2555 } else { | 2842 } else { |
2556 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2843 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2557 } | 2844 } |
2558 } | 2845 } |
| 2846 |
2559 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { | 2847 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { |
2560 int32_t argc = pArguments->GetLength(); | 2848 int32_t argc = pArguments->GetLength(); |
2561 if (argc == 0) { | 2849 if (argc == 0) { |
2562 } else { | 2850 } else { |
2563 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getInvalidObjects"); | 2851 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getInvalidObjects"); |
2564 } | 2852 } |
2565 } | 2853 } |
| 2854 |
2566 int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { | 2855 int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { |
2567 int32_t index = 0; | 2856 int32_t index = 0; |
2568 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2857 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2569 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2858 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2570 if ((pNode->GetElementType() == XFA_Element::Subform) || | 2859 if ((pNode->GetElementType() == XFA_Element::Subform) || |
2571 (pNode->GetElementType() == XFA_Element::SubformSet)) { | 2860 (pNode->GetElementType() == XFA_Element::SubformSet)) { |
2572 index++; | 2861 index++; |
2573 } else { | 2862 } else { |
2574 break; | 2863 break; |
2575 } | 2864 } |
2576 } | 2865 } |
2577 return index; | 2866 return index; |
2578 } | 2867 } |
| 2868 |
2579 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { | 2869 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { |
2580 int32_t argc = pArguments->GetLength(); | 2870 int32_t argc = pArguments->GetLength(); |
2581 if (argc == 1) { | 2871 if (argc == 1) { |
2582 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2872 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2583 } else { | 2873 } else { |
2584 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); | 2874 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); |
2585 } | 2875 } |
2586 } | 2876 } |
| 2877 |
2587 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { | 2878 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { |
2588 int32_t argc = pArguments->GetLength(); | 2879 int32_t argc = pArguments->GetLength(); |
2589 if (argc == 0) { | 2880 if (argc == 0) { |
2590 m_pDocument->DoDataRemerge(TRUE); | 2881 m_pDocument->DoDataRemerge(TRUE); |
2591 } else { | 2882 } else { |
2592 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); | 2883 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); |
2593 } | 2884 } |
2594 } | 2885 } |
| 2886 |
2595 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2887 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2596 int32_t argc = pArguments->GetLength(); | 2888 int32_t argc = pArguments->GetLength(); |
2597 if (argc == 0) { | 2889 if (argc == 0) { |
2598 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2890 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2599 if (!pWidgetData) { | 2891 if (!pWidgetData) { |
2600 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2892 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2601 } else { | 2893 } else { |
2602 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2894 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2603 } | 2895 } |
2604 } else { | 2896 } else { |
2605 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 2897 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
2606 } | 2898 } |
2607 } | 2899 } |
| 2900 |
2608 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { | 2901 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { |
2609 int32_t argc = pArguments->GetLength(); | 2902 int32_t argc = pArguments->GetLength(); |
2610 if ((argc > 0) && (argc < 4)) { | 2903 if ((argc > 0) && (argc < 4)) { |
2611 CFX_WideString strTagName; | 2904 CFX_WideString strTagName; |
2612 CFX_WideString strName; | 2905 CFX_WideString strName; |
2613 CFX_WideString strNameSpace; | 2906 CFX_WideString strNameSpace; |
2614 CFX_ByteString bsTagName = pArguments->GetUTF8String(0); | 2907 CFX_ByteString bsTagName = pArguments->GetUTF8String(0); |
2615 strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC()); | 2908 strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC()); |
2616 if (argc > 1) { | 2909 if (argc > 1) { |
2617 CFX_ByteString bsName = pArguments->GetUTF8String(1); | 2910 CFX_ByteString bsName = pArguments->GetUTF8String(1); |
(...skipping 23 matching lines...) Expand all Loading... |
2641 } | 2934 } |
2642 } else { | 2935 } else { |
2643 pArguments->GetReturnValue()->Assign( | 2936 pArguments->GetReturnValue()->Assign( |
2644 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); | 2937 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); |
2645 } | 2938 } |
2646 } | 2939 } |
2647 } else { | 2940 } else { |
2648 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); | 2941 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); |
2649 } | 2942 } |
2650 } | 2943 } |
| 2944 |
2651 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { | 2945 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { |
2652 if (pArguments->GetLength() == 1) { | 2946 if (pArguments->GetLength() == 1) { |
2653 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2947 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2654 } else { | 2948 } else { |
2655 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); | 2949 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); |
2656 } | 2950 } |
2657 } | 2951 } |
| 2952 |
2658 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2953 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2659 int32_t argc = pArguments->GetLength(); | 2954 int32_t argc = pArguments->GetLength(); |
2660 if (argc == 0) { | 2955 if (argc == 0) { |
2661 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2956 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2662 if (!pWidgetData) { | 2957 if (!pWidgetData) { |
2663 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2958 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2664 } else { | 2959 } else { |
2665 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2960 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2666 } | 2961 } |
2667 } else { | 2962 } else { |
2668 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2963 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2669 } | 2964 } |
2670 } | 2965 } |
| 2966 |
2671 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { | 2967 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { |
2672 int32_t argc = pArguments->GetLength(); | 2968 int32_t argc = pArguments->GetLength(); |
2673 if (argc == 0) { | 2969 if (argc == 0) { |
2674 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2970 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2675 if (!pWidgetData) { | 2971 if (!pWidgetData) { |
2676 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2972 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2677 } else { | 2973 } else { |
2678 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2974 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2679 } | 2975 } |
2680 } else { | 2976 } else { |
2681 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2977 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2682 } | 2978 } |
2683 } | 2979 } |
| 2980 |
2684 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { | 2981 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { |
2685 int32_t argc = pArguments->GetLength(); | 2982 int32_t argc = pArguments->GetLength(); |
2686 if (argc == 0) { | 2983 if (argc == 0) { |
2687 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2984 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2688 if (!pWidgetData) { | 2985 if (!pWidgetData) { |
2689 pArguments->GetReturnValue()->SetBoolean(FALSE); | 2986 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2690 } else { | 2987 } else { |
2691 pArguments->GetReturnValue()->SetBoolean(TRUE); | 2988 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2692 } | 2989 } |
2693 } else { | 2990 } else { |
2694 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); | 2991 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); |
2695 } | 2992 } |
2696 } | 2993 } |
| 2994 |
2697 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, | 2995 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, |
2698 FX_BOOL bSetting, | 2996 FX_BOOL bSetting, |
2699 XFA_ATTRIBUTE eAttribute) { | 2997 XFA_ATTRIBUTE eAttribute) { |
2700 if (bSetting) { | 2998 if (bSetting) { |
2701 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2999 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2702 return; | 3000 return; |
2703 } | 3001 } |
2704 CXFA_Occur nodeOccur(GetOccurNode()); | 3002 CXFA_Occur nodeOccur(GetOccurNode()); |
2705 pValue->SetInteger(nodeOccur.GetMax()); | 3003 pValue->SetInteger(nodeOccur.GetMax()); |
2706 } | 3004 } |
| 3005 |
2707 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, | 3006 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, |
2708 FX_BOOL bSetting, | 3007 FX_BOOL bSetting, |
2709 XFA_ATTRIBUTE eAttribute) { | 3008 XFA_ATTRIBUTE eAttribute) { |
2710 if (bSetting) { | 3009 if (bSetting) { |
2711 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 3010 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2712 return; | 3011 return; |
2713 } | 3012 } |
2714 CXFA_Occur nodeOccur(GetOccurNode()); | 3013 CXFA_Occur nodeOccur(GetOccurNode()); |
2715 pValue->SetInteger(nodeOccur.GetMin()); | 3014 pValue->SetInteger(nodeOccur.GetMin()); |
2716 } | 3015 } |
2717 static int32_t XFA_ScriptInstanceManager_GetCount(CXFA_Node* pInstMgrNode) { | |
2718 ASSERT(pInstMgrNode); | |
2719 int32_t iCount = 0; | |
2720 uint32_t dwNameHash = 0; | |
2721 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
2722 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
2723 XFA_Element eCurType = pNode->GetElementType(); | |
2724 if (eCurType == XFA_Element::InstanceManager) { | |
2725 break; | |
2726 } | |
2727 if ((eCurType != XFA_Element::Subform) && | |
2728 (eCurType != XFA_Element::SubformSet)) { | |
2729 continue; | |
2730 } | |
2731 if (iCount == 0) { | |
2732 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); | |
2733 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); | |
2734 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || | |
2735 wsInstName.Mid(1) != wsName) { | |
2736 return iCount; | |
2737 } | |
2738 dwNameHash = pNode->GetNameHash(); | |
2739 } | |
2740 if (dwNameHash != pNode->GetNameHash()) { | |
2741 break; | |
2742 } | |
2743 iCount++; | |
2744 } | |
2745 return iCount; | |
2746 } | |
2747 static void | |
2748 XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( | |
2749 const CXFA_NodeSet& rgNodeSet, | |
2750 CXFA_NodeArray& rgNodeArray, | |
2751 CFX_ArrayTemplate<int32_t>& rgIdxArray) { | |
2752 int32_t iCount = pdfium::CollectionSize<int32_t>(rgNodeSet); | |
2753 rgNodeArray.SetSize(iCount); | |
2754 rgIdxArray.SetSize(iCount); | |
2755 if (iCount == 0) | |
2756 return; | |
2757 | 3016 |
2758 int32_t iIndex = -1; | |
2759 int32_t iTotalIndex = -1; | |
2760 CXFA_Node* pCommonParent = | |
2761 (*rgNodeSet.begin())->GetNodeItem(XFA_NODEITEM_Parent); | |
2762 for (CXFA_Node* pNode = pCommonParent->GetNodeItem(XFA_NODEITEM_FirstChild); | |
2763 pNode && iIndex < iCount; | |
2764 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
2765 iTotalIndex++; | |
2766 if (pdfium::ContainsValue(rgNodeSet, pNode)) { | |
2767 iIndex++; | |
2768 rgNodeArray[iIndex] = pNode; | |
2769 rgIdxArray[iIndex] = iTotalIndex; | |
2770 } | |
2771 } | |
2772 } | |
2773 | |
2774 using CXFA_NodeSetPair = std::pair<CXFA_NodeSet, CXFA_NodeSet>; | |
2775 using CXFA_NodeSetPairMap = | |
2776 std::map<uint32_t, std::unique_ptr<CXFA_NodeSetPair>>; | |
2777 using CXFA_NodeSetPairMapMap = | |
2778 std::map<CXFA_Node*, std::unique_ptr<CXFA_NodeSetPairMap>>; | |
2779 | |
2780 static CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, | |
2781 CXFA_NodeSetPairMapMap* pMap) { | |
2782 CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); | |
2783 uint32_t dwNameHash = pNode->GetNameHash(); | |
2784 if (!pParentNode || !dwNameHash) | |
2785 return nullptr; | |
2786 | |
2787 if (!(*pMap)[pParentNode]) | |
2788 (*pMap)[pParentNode].reset(new CXFA_NodeSetPairMap); | |
2789 | |
2790 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get(); | |
2791 if (!(*pNodeSetPairMap)[dwNameHash]) | |
2792 (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair); | |
2793 | |
2794 return (*pNodeSetPairMap)[dwNameHash].get(); | |
2795 } | |
2796 | |
2797 static void XFA_ScriptInstanceManager_ReorderDataNodes( | |
2798 const CXFA_NodeSet& sSet1, | |
2799 const CXFA_NodeSet& sSet2, | |
2800 FX_BOOL bInsertBefore) { | |
2801 CXFA_NodeSetPairMapMap rgMap; | |
2802 for (CXFA_Node* pNode : sSet1) { | |
2803 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); | |
2804 if (pNodeSetPair) | |
2805 pNodeSetPair->first.insert(pNode); | |
2806 } | |
2807 for (CXFA_Node* pNode : sSet2) { | |
2808 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); | |
2809 if (pNodeSetPair) { | |
2810 if (pdfium::ContainsValue(pNodeSetPair->first, pNode)) | |
2811 pNodeSetPair->first.erase(pNode); | |
2812 else | |
2813 pNodeSetPair->second.insert(pNode); | |
2814 } | |
2815 } | |
2816 for (const auto& iter1 : rgMap) { | |
2817 CXFA_NodeSetPairMap* pNodeSetPairMap = iter1.second.get(); | |
2818 if (!pNodeSetPairMap) { | |
2819 continue; | |
2820 } | |
2821 for (const auto& iter2 : *pNodeSetPairMap) { | |
2822 CXFA_NodeSetPair* pNodeSetPair = iter2.second.get(); | |
2823 if (!pNodeSetPair) { | |
2824 continue; | |
2825 } | |
2826 if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) { | |
2827 CXFA_NodeArray rgNodeArray1; | |
2828 CXFA_NodeArray rgNodeArray2; | |
2829 CFX_ArrayTemplate<int32_t> rgIdxArray1; | |
2830 CFX_ArrayTemplate<int32_t> rgIdxArray2; | |
2831 XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( | |
2832 pNodeSetPair->first, rgNodeArray1, rgIdxArray1); | |
2833 XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( | |
2834 pNodeSetPair->second, rgNodeArray2, rgIdxArray2); | |
2835 CXFA_Node* pParentNode = nullptr; | |
2836 CXFA_Node* pBeforeNode = nullptr; | |
2837 if (bInsertBefore) { | |
2838 pBeforeNode = rgNodeArray2[0]; | |
2839 pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent); | |
2840 } else { | |
2841 CXFA_Node* pLastNode = rgNodeArray2[rgIdxArray2.GetSize() - 1]; | |
2842 pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent); | |
2843 pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
2844 } | |
2845 for (int32_t iIdx = 0; iIdx < rgIdxArray1.GetSize(); iIdx++) { | |
2846 CXFA_Node* pCurNode = rgNodeArray1[iIdx]; | |
2847 pParentNode->RemoveChild(pCurNode); | |
2848 pParentNode->InsertChild(pCurNode, pBeforeNode); | |
2849 } | |
2850 } | |
2851 } | |
2852 pNodeSetPairMap->clear(); | |
2853 } | |
2854 } | |
2855 | |
2856 static void XFA_ScriptInstanceManager_InsertItem( | |
2857 CXFA_Node* pInstMgrNode, | |
2858 CXFA_Node* pNewInstance, | |
2859 int32_t iPos, | |
2860 int32_t iCount = -1, | |
2861 FX_BOOL bMoveDataBindingNodes = TRUE) { | |
2862 if (iCount < 0) { | |
2863 iCount = XFA_ScriptInstanceManager_GetCount(pInstMgrNode); | |
2864 } | |
2865 if (iPos < 0) { | |
2866 iPos = iCount; | |
2867 } | |
2868 if (iPos == iCount) { | |
2869 CXFA_Node* pNextSibling = | |
2870 iCount > 0 | |
2871 ? XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iCount - 1) | |
2872 ->GetNodeItem(XFA_NODEITEM_NextSibling) | |
2873 : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
2874 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) | |
2875 ->InsertChild(pNewInstance, pNextSibling); | |
2876 if (bMoveDataBindingNodes) { | |
2877 CXFA_NodeSet sNew; | |
2878 CXFA_NodeSet sAfter; | |
2879 CXFA_NodeIteratorTemplate<CXFA_Node, | |
2880 CXFA_TraverseStrategy_XFAContainerNode> | |
2881 sIteratorNew(pNewInstance); | |
2882 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; | |
2883 pNode = sIteratorNew.MoveToNext()) { | |
2884 CXFA_Node* pDataNode = pNode->GetBindData(); | |
2885 if (!pDataNode) { | |
2886 continue; | |
2887 } | |
2888 sNew.insert(pDataNode); | |
2889 } | |
2890 CXFA_NodeIteratorTemplate<CXFA_Node, | |
2891 CXFA_TraverseStrategy_XFAContainerNode> | |
2892 sIteratorAfter(pNextSibling); | |
2893 for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode; | |
2894 pNode = sIteratorAfter.MoveToNext()) { | |
2895 CXFA_Node* pDataNode = pNode->GetBindData(); | |
2896 if (!pDataNode) { | |
2897 continue; | |
2898 } | |
2899 sAfter.insert(pDataNode); | |
2900 } | |
2901 XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sAfter, FALSE); | |
2902 } | |
2903 } else { | |
2904 CXFA_Node* pBeforeInstance = | |
2905 XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iPos); | |
2906 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) | |
2907 ->InsertChild(pNewInstance, pBeforeInstance); | |
2908 if (bMoveDataBindingNodes) { | |
2909 CXFA_NodeSet sNew; | |
2910 CXFA_NodeSet sBefore; | |
2911 CXFA_NodeIteratorTemplate<CXFA_Node, | |
2912 CXFA_TraverseStrategy_XFAContainerNode> | |
2913 sIteratorNew(pNewInstance); | |
2914 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; | |
2915 pNode = sIteratorNew.MoveToNext()) { | |
2916 CXFA_Node* pDataNode = pNode->GetBindData(); | |
2917 if (!pDataNode) { | |
2918 continue; | |
2919 } | |
2920 sNew.insert(pDataNode); | |
2921 } | |
2922 CXFA_NodeIteratorTemplate<CXFA_Node, | |
2923 CXFA_TraverseStrategy_XFAContainerNode> | |
2924 sIteratorBefore(pBeforeInstance); | |
2925 for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode; | |
2926 pNode = sIteratorBefore.MoveToNext()) { | |
2927 CXFA_Node* pDataNode = pNode->GetBindData(); | |
2928 if (!pDataNode) { | |
2929 continue; | |
2930 } | |
2931 sBefore.insert(pDataNode); | |
2932 } | |
2933 XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sBefore, TRUE); | |
2934 } | |
2935 } | |
2936 } | |
2937 static void XFA_ScriptInstanceManager_RemoveItem( | |
2938 CXFA_Node* pInstMgrNode, | |
2939 CXFA_Node* pRemoveInstance, | |
2940 FX_BOOL bRemoveDataBinding = TRUE) { | |
2941 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance); | |
2942 if (!bRemoveDataBinding) { | |
2943 return; | |
2944 } | |
2945 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> | |
2946 sIterator(pRemoveInstance); | |
2947 for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode; | |
2948 pFormNode = sIterator.MoveToNext()) { | |
2949 CXFA_Node* pDataNode = pFormNode->GetBindData(); | |
2950 if (!pDataNode) { | |
2951 continue; | |
2952 } | |
2953 if (pDataNode->RemoveBindItem(pFormNode) == 0) { | |
2954 if (CXFA_Node* pDataParent = | |
2955 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { | |
2956 pDataParent->RemoveChild(pDataNode); | |
2957 } | |
2958 } | |
2959 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); | |
2960 } | |
2961 } | |
2962 static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance( | |
2963 CXFA_Node* pInstMgrNode, | |
2964 FX_BOOL bDataMerge) { | |
2965 CXFA_Document* pDocument = pInstMgrNode->GetDocument(); | |
2966 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); | |
2967 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); | |
2968 CXFA_Node* pDataScope = nullptr; | |
2969 for (CXFA_Node* pRootBoundNode = pFormParent; | |
2970 pRootBoundNode && pRootBoundNode->IsContainerNode(); | |
2971 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { | |
2972 pDataScope = pRootBoundNode->GetBindData(); | |
2973 if (pDataScope) { | |
2974 break; | |
2975 } | |
2976 } | |
2977 if (!pDataScope) { | |
2978 pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); | |
2979 ASSERT(pDataScope); | |
2980 } | |
2981 CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer( | |
2982 pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge, TRUE); | |
2983 if (pInstance) { | |
2984 pDocument->DataMerge_UpdateBindingRelations(pInstance); | |
2985 pFormParent->RemoveChild(pInstance); | |
2986 } | |
2987 return pInstance; | |
2988 } | |
2989 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, | 3017 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, |
2990 FX_BOOL bSetting, | 3018 FX_BOOL bSetting, |
2991 XFA_ATTRIBUTE eAttribute) { | 3019 XFA_ATTRIBUTE eAttribute) { |
2992 if (bSetting) { | 3020 if (bSetting) { |
2993 int32_t iDesired = pValue->ToInteger(); | 3021 int32_t iDesired = pValue->ToInteger(); |
2994 InstanceManager_SetInstances(iDesired); | 3022 InstanceManager_SetInstances(iDesired); |
2995 } else { | 3023 } else { |
2996 pValue->SetInteger(XFA_ScriptInstanceManager_GetCount(this)); | 3024 pValue->SetInteger(GetCount(this)); |
2997 } | 3025 } |
2998 } | 3026 } |
| 3027 |
2999 void CXFA_Node::Script_InstanceManager_MoveInstance( | 3028 void CXFA_Node::Script_InstanceManager_MoveInstance( |
3000 CFXJSE_Arguments* pArguments) { | 3029 CFXJSE_Arguments* pArguments) { |
3001 int32_t argc = pArguments->GetLength(); | 3030 int32_t argc = pArguments->GetLength(); |
3002 if (argc != 2) { | 3031 if (argc != 2) { |
3003 pArguments->GetReturnValue()->SetUndefined(); | 3032 pArguments->GetReturnValue()->SetUndefined(); |
3004 return; | 3033 return; |
3005 } | 3034 } |
3006 int32_t iFrom = pArguments->GetInt32(0); | 3035 int32_t iFrom = pArguments->GetInt32(0); |
3007 int32_t iTo = pArguments->GetInt32(1); | 3036 int32_t iTo = pArguments->GetInt32(1); |
3008 InstanceManager_MoveInstance(iTo, iFrom); | 3037 InstanceManager_MoveInstance(iTo, iFrom); |
3009 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3038 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3010 if (!pNotify) { | 3039 if (!pNotify) { |
3011 return; | 3040 return; |
3012 } | 3041 } |
3013 CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); | 3042 CXFA_Node* pToInstance = GetItem(this, iTo); |
3014 if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) { | 3043 if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) { |
3015 pNotify->RunSubformIndexChange(pToInstance); | 3044 pNotify->RunSubformIndexChange(pToInstance); |
3016 } | 3045 } |
3017 CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); | 3046 CXFA_Node* pFromInstance = GetItem(this, iFrom); |
3018 if (pFromInstance && | 3047 if (pFromInstance && |
3019 pFromInstance->GetElementType() == XFA_Element::Subform) { | 3048 pFromInstance->GetElementType() == XFA_Element::Subform) { |
3020 pNotify->RunSubformIndexChange(pFromInstance); | 3049 pNotify->RunSubformIndexChange(pFromInstance); |
3021 } | 3050 } |
3022 } | 3051 } |
| 3052 |
3023 void CXFA_Node::Script_InstanceManager_RemoveInstance( | 3053 void CXFA_Node::Script_InstanceManager_RemoveInstance( |
3024 CFXJSE_Arguments* pArguments) { | 3054 CFXJSE_Arguments* pArguments) { |
3025 int32_t argc = pArguments->GetLength(); | 3055 int32_t argc = pArguments->GetLength(); |
3026 if (argc != 1) { | 3056 if (argc != 1) { |
3027 pArguments->GetReturnValue()->SetUndefined(); | 3057 pArguments->GetReturnValue()->SetUndefined(); |
3028 return; | 3058 return; |
3029 } | 3059 } |
3030 int32_t iIndex = pArguments->GetInt32(0); | 3060 int32_t iIndex = pArguments->GetInt32(0); |
3031 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3061 int32_t iCount = GetCount(this); |
3032 if (iIndex < 0 || iIndex >= iCount) { | 3062 if (iIndex < 0 || iIndex >= iCount) { |
3033 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | 3063 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); |
3034 return; | 3064 return; |
3035 } | 3065 } |
3036 CXFA_Occur nodeOccur(GetOccurNode()); | 3066 CXFA_Occur nodeOccur(GetOccurNode()); |
3037 int32_t iMin = nodeOccur.GetMin(); | 3067 int32_t iMin = nodeOccur.GetMin(); |
3038 if (iCount - 1 < iMin) { | 3068 if (iCount - 1 < iMin) { |
3039 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min"); | 3069 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min"); |
3040 return; | 3070 return; |
3041 } | 3071 } |
3042 CXFA_Node* pRemoveInstance = XFA_ScriptInstanceManager_GetItem(this, iIndex); | 3072 CXFA_Node* pRemoveInstance = GetItem(this, iIndex); |
3043 XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); | 3073 RemoveItem(this, pRemoveInstance); |
3044 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3074 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3045 if (pNotify) { | 3075 if (pNotify) { |
3046 for (int32_t i = iIndex; i < iCount - 1; i++) { | 3076 for (int32_t i = iIndex; i < iCount - 1; i++) { |
3047 CXFA_Node* pSubformInstance = XFA_ScriptInstanceManager_GetItem(this, i); | 3077 CXFA_Node* pSubformInstance = GetItem(this, i); |
3048 if (pSubformInstance && | 3078 if (pSubformInstance && |
3049 pSubformInstance->GetElementType() == XFA_Element::Subform) { | 3079 pSubformInstance->GetElementType() == XFA_Element::Subform) { |
3050 pNotify->RunSubformIndexChange(pSubformInstance); | 3080 pNotify->RunSubformIndexChange(pSubformInstance); |
3051 } | 3081 } |
3052 } | 3082 } |
3053 } | 3083 } |
3054 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3084 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3055 if (!pLayoutPro) { | 3085 if (!pLayoutPro) { |
3056 return; | 3086 return; |
3057 } | 3087 } |
3058 pLayoutPro->AddChangedContainer( | 3088 pLayoutPro->AddChangedContainer( |
3059 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3089 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3060 } | 3090 } |
| 3091 |
3061 void CXFA_Node::Script_InstanceManager_SetInstances( | 3092 void CXFA_Node::Script_InstanceManager_SetInstances( |
3062 CFXJSE_Arguments* pArguments) { | 3093 CFXJSE_Arguments* pArguments) { |
3063 int32_t argc = pArguments->GetLength(); | 3094 int32_t argc = pArguments->GetLength(); |
3064 if (argc != 1) { | 3095 if (argc != 1) { |
3065 pArguments->GetReturnValue()->SetUndefined(); | 3096 pArguments->GetReturnValue()->SetUndefined(); |
3066 return; | 3097 return; |
3067 } | 3098 } |
3068 int32_t iDesired = pArguments->GetInt32(0); | 3099 int32_t iDesired = pArguments->GetInt32(0); |
3069 InstanceManager_SetInstances(iDesired); | 3100 InstanceManager_SetInstances(iDesired); |
3070 } | 3101 } |
| 3102 |
3071 void CXFA_Node::Script_InstanceManager_AddInstance( | 3103 void CXFA_Node::Script_InstanceManager_AddInstance( |
3072 CFXJSE_Arguments* pArguments) { | 3104 CFXJSE_Arguments* pArguments) { |
3073 int32_t argc = pArguments->GetLength(); | 3105 int32_t argc = pArguments->GetLength(); |
3074 if ((argc != 0) && (argc != 1)) { | 3106 if ((argc != 0) && (argc != 1)) { |
3075 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); | 3107 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); |
3076 return; | 3108 return; |
3077 } | 3109 } |
3078 FX_BOOL fFlags = TRUE; | 3110 FX_BOOL fFlags = TRUE; |
3079 if (argc == 1) { | 3111 if (argc == 1) { |
3080 fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; | 3112 fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; |
3081 } | 3113 } |
3082 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3114 int32_t iCount = GetCount(this); |
3083 CXFA_Occur nodeOccur(GetOccurNode()); | 3115 CXFA_Occur nodeOccur(GetOccurNode()); |
3084 int32_t iMax = nodeOccur.GetMax(); | 3116 int32_t iMax = nodeOccur.GetMax(); |
3085 if (iMax >= 0 && iCount >= iMax) { | 3117 if (iMax >= 0 && iCount >= iMax) { |
3086 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); | 3118 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); |
3087 return; | 3119 return; |
3088 } | 3120 } |
3089 CXFA_Node* pNewInstance = | 3121 CXFA_Node* pNewInstance = CreateInstance(this, fFlags); |
3090 XFA_ScriptInstanceManager_CreateInstance(this, fFlags); | 3122 InsertItem(this, pNewInstance, iCount, iCount, FALSE); |
3091 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, | |
3092 FALSE); | |
3093 pArguments->GetReturnValue()->Assign( | 3123 pArguments->GetReturnValue()->Assign( |
3094 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); | 3124 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); |
3095 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3125 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3096 if (!pNotify) { | 3126 if (!pNotify) { |
3097 return; | 3127 return; |
3098 } | 3128 } |
3099 pNotify->RunNodeInitialize(pNewInstance); | 3129 pNotify->RunNodeInitialize(pNewInstance); |
3100 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3130 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3101 if (!pLayoutPro) { | 3131 if (!pLayoutPro) { |
3102 return; | 3132 return; |
3103 } | 3133 } |
3104 pLayoutPro->AddChangedContainer( | 3134 pLayoutPro->AddChangedContainer( |
3105 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3135 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3106 } | 3136 } |
| 3137 |
3107 void CXFA_Node::Script_InstanceManager_InsertInstance( | 3138 void CXFA_Node::Script_InstanceManager_InsertInstance( |
3108 CFXJSE_Arguments* pArguments) { | 3139 CFXJSE_Arguments* pArguments) { |
3109 int32_t argc = pArguments->GetLength(); | 3140 int32_t argc = pArguments->GetLength(); |
3110 if ((argc != 1) && (argc != 2)) { | 3141 if ((argc != 1) && (argc != 2)) { |
3111 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insertInstance"); | 3142 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insertInstance"); |
3112 return; | 3143 return; |
3113 } | 3144 } |
3114 int32_t iIndex = pArguments->GetInt32(0); | 3145 int32_t iIndex = pArguments->GetInt32(0); |
3115 FX_BOOL bBind = FALSE; | 3146 FX_BOOL bBind = FALSE; |
3116 if (argc == 2) { | 3147 if (argc == 2) { |
3117 bBind = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | 3148 bBind = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; |
3118 } | 3149 } |
3119 CXFA_Occur nodeOccur(GetOccurNode()); | 3150 CXFA_Occur nodeOccur(GetOccurNode()); |
3120 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3151 int32_t iCount = GetCount(this); |
3121 if (iIndex < 0 || iIndex > iCount) { | 3152 if (iIndex < 0 || iIndex > iCount) { |
3122 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | 3153 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); |
3123 return; | 3154 return; |
3124 } | 3155 } |
3125 int32_t iMax = nodeOccur.GetMax(); | 3156 int32_t iMax = nodeOccur.GetMax(); |
3126 if (iMax >= 0 && iCount >= iMax) { | 3157 if (iMax >= 0 && iCount >= iMax) { |
3127 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); | 3158 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); |
3128 return; | 3159 return; |
3129 } | 3160 } |
3130 CXFA_Node* pNewInstance = | 3161 CXFA_Node* pNewInstance = CreateInstance(this, bBind); |
3131 XFA_ScriptInstanceManager_CreateInstance(this, bBind); | 3162 InsertItem(this, pNewInstance, iIndex, iCount, TRUE); |
3132 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, | |
3133 TRUE); | |
3134 pArguments->GetReturnValue()->Assign( | 3163 pArguments->GetReturnValue()->Assign( |
3135 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); | 3164 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); |
3136 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3165 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3137 if (!pNotify) { | 3166 if (!pNotify) { |
3138 return; | 3167 return; |
3139 } | 3168 } |
3140 pNotify->RunNodeInitialize(pNewInstance); | 3169 pNotify->RunNodeInitialize(pNewInstance); |
3141 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3170 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3142 if (!pLayoutPro) { | 3171 if (!pLayoutPro) { |
3143 return; | 3172 return; |
3144 } | 3173 } |
3145 pLayoutPro->AddChangedContainer( | 3174 pLayoutPro->AddChangedContainer( |
3146 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3175 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3147 } | 3176 } |
| 3177 |
3148 int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) { | 3178 int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) { |
3149 CXFA_Occur nodeOccur(GetOccurNode()); | 3179 CXFA_Occur nodeOccur(GetOccurNode()); |
3150 int32_t iMax = nodeOccur.GetMax(); | 3180 int32_t iMax = nodeOccur.GetMax(); |
3151 int32_t iMin = nodeOccur.GetMin(); | 3181 int32_t iMin = nodeOccur.GetMin(); |
3152 if (iDesired < iMin) { | 3182 if (iDesired < iMin) { |
3153 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min"); | 3183 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min"); |
3154 return 1; | 3184 return 1; |
3155 } | 3185 } |
3156 if ((iMax >= 0) && (iDesired > iMax)) { | 3186 if ((iMax >= 0) && (iDesired > iMax)) { |
3157 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); | 3187 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); |
3158 return 2; | 3188 return 2; |
3159 } | 3189 } |
3160 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3190 int32_t iCount = GetCount(this); |
3161 if (iDesired == iCount) { | 3191 if (iDesired == iCount) { |
3162 return 0; | 3192 return 0; |
3163 } | 3193 } |
3164 if (iDesired < iCount) { | 3194 if (iDesired < iCount) { |
3165 CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name); | 3195 CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name); |
3166 CFX_WideString wsInstanceName = | 3196 CFX_WideString wsInstanceName = |
3167 CFX_WideString(wsInstManagerName.IsEmpty() ? wsInstManagerName | 3197 CFX_WideString(wsInstManagerName.IsEmpty() ? wsInstManagerName |
3168 : wsInstManagerName.Mid(1)); | 3198 : wsInstManagerName.Mid(1)); |
3169 uint32_t dInstanceNameHash = | 3199 uint32_t dInstanceNameHash = |
3170 FX_HashCode_GetW(wsInstanceName.AsStringC(), false); | 3200 FX_HashCode_GetW(wsInstanceName.AsStringC(), false); |
3171 CXFA_Node* pPrevSibling = | 3201 CXFA_Node* pPrevSibling = |
3172 (iDesired == 0) ? this | 3202 (iDesired == 0) ? this : GetItem(this, iDesired - 1); |
3173 : XFA_ScriptInstanceManager_GetItem(this, iDesired - 1); | |
3174 while (iCount > iDesired) { | 3203 while (iCount > iDesired) { |
3175 CXFA_Node* pRemoveInstance = | 3204 CXFA_Node* pRemoveInstance = |
3176 pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); | 3205 pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); |
3177 if (pRemoveInstance->GetElementType() != XFA_Element::Subform && | 3206 if (pRemoveInstance->GetElementType() != XFA_Element::Subform && |
3178 pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { | 3207 pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { |
3179 continue; | 3208 continue; |
3180 } | 3209 } |
3181 if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { | 3210 if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { |
3182 ASSERT(FALSE); | 3211 ASSERT(FALSE); |
3183 break; | 3212 break; |
3184 } | 3213 } |
3185 if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { | 3214 if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { |
3186 XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); | 3215 RemoveItem(this, pRemoveInstance); |
3187 iCount--; | 3216 iCount--; |
3188 } | 3217 } |
3189 } | 3218 } |
3190 } else if (iDesired > iCount) { | 3219 } else if (iDesired > iCount) { |
3191 while (iCount < iDesired) { | 3220 while (iCount < iDesired) { |
3192 CXFA_Node* pNewInstance = | 3221 CXFA_Node* pNewInstance = CreateInstance(this, TRUE); |
3193 XFA_ScriptInstanceManager_CreateInstance(this, TRUE); | 3222 InsertItem(this, pNewInstance, iCount, iCount, FALSE); |
3194 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, | |
3195 FALSE); | |
3196 iCount++; | 3223 iCount++; |
3197 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3224 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3198 if (!pNotify) { | 3225 if (!pNotify) { |
3199 return 0; | 3226 return 0; |
3200 } | 3227 } |
3201 pNotify->RunNodeInitialize(pNewInstance); | 3228 pNotify->RunNodeInitialize(pNewInstance); |
3202 } | 3229 } |
3203 } | 3230 } |
3204 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3231 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3205 if (pLayoutPro) { | 3232 if (pLayoutPro) { |
3206 pLayoutPro->AddChangedContainer( | 3233 pLayoutPro->AddChangedContainer( |
3207 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3234 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3208 } | 3235 } |
3209 return 0; | 3236 return 0; |
3210 } | 3237 } |
| 3238 |
3211 int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { | 3239 int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { |
3212 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3240 int32_t iCount = GetCount(this); |
3213 if (iFrom > iCount || iTo > iCount - 1) { | 3241 if (iFrom > iCount || iTo > iCount - 1) { |
3214 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | 3242 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); |
3215 return 1; | 3243 return 1; |
3216 } | 3244 } |
3217 if (iFrom < 0 || iTo < 0 || iFrom == iTo) { | 3245 if (iFrom < 0 || iTo < 0 || iFrom == iTo) { |
3218 return 0; | 3246 return 0; |
3219 } | 3247 } |
3220 CXFA_Node* pMoveInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); | 3248 CXFA_Node* pMoveInstance = GetItem(this, iFrom); |
3221 XFA_ScriptInstanceManager_RemoveItem(this, pMoveInstance, FALSE); | 3249 RemoveItem(this, pMoveInstance, FALSE); |
3222 XFA_ScriptInstanceManager_InsertItem(this, pMoveInstance, iTo, iCount - 1, | 3250 InsertItem(this, pMoveInstance, iTo, iCount - 1, TRUE); |
3223 TRUE); | |
3224 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3251 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3225 if (pLayoutPro) { | 3252 if (pLayoutPro) { |
3226 pLayoutPro->AddChangedContainer( | 3253 pLayoutPro->AddChangedContainer( |
3227 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3254 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3228 } | 3255 } |
3229 return 0; | 3256 return 0; |
3230 } | 3257 } |
| 3258 |
3231 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, | 3259 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, |
3232 FX_BOOL bSetting, | 3260 FX_BOOL bSetting, |
3233 XFA_ATTRIBUTE eAttribute) { | 3261 XFA_ATTRIBUTE eAttribute) { |
3234 CXFA_Occur occur(this); | 3262 CXFA_Occur occur(this); |
3235 if (bSetting) { | 3263 if (bSetting) { |
3236 int32_t iMax = pValue->ToInteger(); | 3264 int32_t iMax = pValue->ToInteger(); |
3237 occur.SetMax(iMax); | 3265 occur.SetMax(iMax); |
3238 } else { | 3266 } else { |
3239 pValue->SetInteger(occur.GetMax()); | 3267 pValue->SetInteger(occur.GetMax()); |
3240 } | 3268 } |
3241 } | 3269 } |
| 3270 |
3242 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, | 3271 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, |
3243 FX_BOOL bSetting, | 3272 FX_BOOL bSetting, |
3244 XFA_ATTRIBUTE eAttribute) { | 3273 XFA_ATTRIBUTE eAttribute) { |
3245 CXFA_Occur occur(this); | 3274 CXFA_Occur occur(this); |
3246 if (bSetting) { | 3275 if (bSetting) { |
3247 int32_t iMin = pValue->ToInteger(); | 3276 int32_t iMin = pValue->ToInteger(); |
3248 occur.SetMin(iMin); | 3277 occur.SetMin(iMin); |
3249 } else { | 3278 } else { |
3250 pValue->SetInteger(occur.GetMin()); | 3279 pValue->SetInteger(occur.GetMin()); |
3251 } | 3280 } |
3252 } | 3281 } |
| 3282 |
3253 void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { | 3283 void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { |
3254 int32_t argc = pArguments->GetLength(); | 3284 int32_t argc = pArguments->GetLength(); |
3255 if ((argc == 0) || (argc == 1)) { | 3285 if ((argc == 0) || (argc == 1)) { |
3256 pArguments->GetReturnValue()->SetString(""); | 3286 pArguments->GetReturnValue()->SetString(""); |
3257 } else { | 3287 } else { |
3258 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); | 3288 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); |
3259 } | 3289 } |
3260 } | 3290 } |
| 3291 |
3261 void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { | 3292 void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { |
3262 int32_t argc = pArguments->GetLength(); | 3293 int32_t argc = pArguments->GetLength(); |
3263 if (argc == 1) { | 3294 if (argc == 1) { |
3264 CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 3295 CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
3265 if (pDataNode) { | 3296 if (pDataNode) { |
3266 CXFA_NodeArray formItems; | 3297 CXFA_NodeArray formItems; |
3267 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); | 3298 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); |
3268 pFormNodes->SetArrayNodeList(formItems); | 3299 pFormNodes->SetArrayNodeList(formItems); |
3269 pArguments->GetReturnValue()->SetObject( | 3300 pArguments->GetReturnValue()->SetObject( |
3270 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); | 3301 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
3271 } else { | 3302 } else { |
3272 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 3303 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
3273 } | 3304 } |
3274 } else { | 3305 } else { |
3275 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); | 3306 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); |
3276 } | 3307 } |
3277 } | 3308 } |
| 3309 |
3278 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { | 3310 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { |
3279 int32_t argc = pArguments->GetLength(); | 3311 int32_t argc = pArguments->GetLength(); |
3280 if (argc == 0) { | 3312 if (argc == 0) { |
3281 m_pDocument->DoDataRemerge(TRUE); | 3313 m_pDocument->DoDataRemerge(TRUE); |
3282 } else { | 3314 } else { |
3283 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); | 3315 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); |
3284 } | 3316 } |
3285 } | 3317 } |
| 3318 |
3286 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { | 3319 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { |
3287 int32_t argc = pArguments->GetLength(); | 3320 int32_t argc = pArguments->GetLength(); |
3288 if (argc == 0) { | 3321 if (argc == 0) { |
3289 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3322 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3290 if (!pNotify) { | 3323 if (!pNotify) { |
3291 return; | 3324 return; |
3292 } | 3325 } |
3293 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); | 3326 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); |
3294 } else { | 3327 } else { |
3295 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 3328 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
3296 } | 3329 } |
3297 } | 3330 } |
| 3331 |
3298 void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { | 3332 void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { |
3299 CXFA_EventParam* pEventParam = | 3333 CXFA_EventParam* pEventParam = |
3300 m_pDocument->GetScriptContext()->GetEventParam(); | 3334 m_pDocument->GetScriptContext()->GetEventParam(); |
3301 if (pEventParam->m_eType == XFA_EVENT_Calculate || | 3335 if (pEventParam->m_eType == XFA_EVENT_Calculate || |
3302 pEventParam->m_eType == XFA_EVENT_InitCalculate) { | 3336 pEventParam->m_eType == XFA_EVENT_InitCalculate) { |
3303 return; | 3337 return; |
3304 } | 3338 } |
3305 int32_t argc = pArguments->GetLength(); | 3339 int32_t argc = pArguments->GetLength(); |
3306 if (argc == 1) { | 3340 if (argc == 1) { |
3307 const bool bScriptFlags = pArguments->GetInt32(0) != 0; | 3341 const bool bScriptFlags = pArguments->GetInt32(0) != 0; |
3308 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3342 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3309 if (!pNotify) { | 3343 if (!pNotify) { |
3310 return; | 3344 return; |
3311 } | 3345 } |
3312 if (bScriptFlags) { | 3346 if (bScriptFlags) { |
3313 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 3347 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
3314 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 3348 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
3315 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); | 3349 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); |
3316 } else { | 3350 } else { |
3317 } | 3351 } |
3318 } else { | 3352 } else { |
3319 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); | 3353 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); |
3320 } | 3354 } |
3321 } | 3355 } |
| 3356 |
3322 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { | 3357 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { |
3323 int32_t argc = pArguments->GetLength(); | 3358 int32_t argc = pArguments->GetLength(); |
3324 if (argc == 0) { | 3359 if (argc == 0) { |
3325 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3360 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3326 if (!pNotify) { | 3361 if (!pNotify) { |
3327 return; | 3362 return; |
3328 } | 3363 } |
3329 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 3364 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
3330 } else { | 3365 } else { |
3331 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 3366 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
3332 } | 3367 } |
3333 } | 3368 } |
| 3369 |
3334 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { | 3370 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { |
3335 int32_t argc = pArguments->GetLength(); | 3371 int32_t argc = pArguments->GetLength(); |
3336 if (argc == 0) { | 3372 if (argc == 0) { |
3337 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 3373 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
3338 if (!pNotify) { | 3374 if (!pNotify) { |
3339 pArguments->GetReturnValue()->SetBoolean(FALSE); | 3375 pArguments->GetReturnValue()->SetBoolean(FALSE); |
3340 } else { | 3376 } else { |
3341 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 3377 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
3342 pArguments->GetReturnValue()->SetBoolean( | 3378 pArguments->GetReturnValue()->SetBoolean( |
3343 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); | 3379 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
3344 } | 3380 } |
3345 } else { | 3381 } else { |
3346 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 3382 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
3347 } | 3383 } |
3348 } | 3384 } |
| 3385 |
3349 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, | 3386 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, |
3350 FX_BOOL bSetting, | 3387 FX_BOOL bSetting, |
3351 XFA_ATTRIBUTE eAttribute) { | 3388 XFA_ATTRIBUTE eAttribute) { |
3352 if (bSetting) { | 3389 if (bSetting) { |
3353 SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC()); | 3390 SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC()); |
3354 } else { | 3391 } else { |
3355 CFX_WideString wsChecksum; | 3392 CFX_WideString wsChecksum; |
3356 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); | 3393 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); |
3357 pValue->SetString( | 3394 pValue->SetString( |
3358 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); | 3395 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); |
3359 } | 3396 } |
3360 } | 3397 } |
| 3398 |
3361 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { | 3399 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { |
3362 int32_t argc = pArguments->GetLength(); | 3400 int32_t argc = pArguments->GetLength(); |
3363 if (argc == 1) { | 3401 if (argc == 1) { |
3364 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); | 3402 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); |
3365 CFX_WideString wsAttributeValue; | 3403 CFX_WideString wsAttributeValue; |
3366 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3404 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3367 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3405 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3368 static_cast<CFDE_XMLElement*>(pXMLNode)->GetString( | 3406 static_cast<CFDE_XMLElement*>(pXMLNode)->GetString( |
3369 CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(), | 3407 CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(), |
3370 wsAttributeValue); | 3408 wsAttributeValue); |
3371 } | 3409 } |
3372 pArguments->GetReturnValue()->SetString( | 3410 pArguments->GetReturnValue()->SetString( |
3373 FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength()) | 3411 FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength()) |
3374 .AsStringC()); | 3412 .AsStringC()); |
3375 } else { | 3413 } else { |
3376 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); | 3414 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); |
3377 } | 3415 } |
3378 } | 3416 } |
| 3417 |
3379 void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { | 3418 void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { |
3380 int32_t argc = pArguments->GetLength(); | 3419 int32_t argc = pArguments->GetLength(); |
3381 if (argc == 2) { | 3420 if (argc == 2) { |
3382 CFX_ByteString bsValue = pArguments->GetUTF8String(0); | 3421 CFX_ByteString bsValue = pArguments->GetUTF8String(0); |
3383 CFX_ByteString bsName = pArguments->GetUTF8String(1); | 3422 CFX_ByteString bsName = pArguments->GetUTF8String(1); |
3384 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3423 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3385 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3424 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3386 static_cast<CFDE_XMLElement*>(pXMLNode) | 3425 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString( |
3387 ->SetString(CFX_WideString::FromUTF8(bsName.AsStringC()), | 3426 CFX_WideString::FromUTF8(bsName.AsStringC()), |
3388 CFX_WideString::FromUTF8(bsValue.AsStringC())); | 3427 CFX_WideString::FromUTF8(bsValue.AsStringC())); |
3389 } | 3428 } |
3390 pArguments->GetReturnValue()->SetNull(); | 3429 pArguments->GetReturnValue()->SetNull(); |
3391 } else { | 3430 } else { |
3392 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); | 3431 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); |
3393 } | 3432 } |
3394 } | 3433 } |
| 3434 |
3395 void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { | 3435 void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { |
3396 int32_t argc = pArguments->GetLength(); | 3436 int32_t argc = pArguments->GetLength(); |
3397 if (argc == 1) { | 3437 if (argc == 1) { |
3398 CFX_ByteString bsName = pArguments->GetUTF8String(0); | 3438 CFX_ByteString bsName = pArguments->GetUTF8String(0); |
3399 CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC()); | 3439 CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC()); |
3400 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3440 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3401 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3441 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3402 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3442 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3403 if (pXMLElement->HasAttribute(wsName.c_str())) { | 3443 if (pXMLElement->HasAttribute(wsName.c_str())) { |
3404 pXMLElement->RemoveAttribute(wsName.c_str()); | 3444 pXMLElement->RemoveAttribute(wsName.c_str()); |
3405 } | 3445 } |
3406 } | 3446 } |
3407 pArguments->GetReturnValue()->SetNull(); | 3447 pArguments->GetReturnValue()->SetNull(); |
3408 } else { | 3448 } else { |
3409 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute"); | 3449 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute"); |
3410 } | 3450 } |
3411 } | 3451 } |
| 3452 |
3412 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, | 3453 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, |
3413 FX_BOOL bSetting, | 3454 FX_BOOL bSetting, |
3414 XFA_ATTRIBUTE eAttribute) { | 3455 XFA_ATTRIBUTE eAttribute) { |
3415 if (bSetting) { | 3456 if (bSetting) { |
3416 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3457 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3417 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3458 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3418 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3459 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3419 pXMLElement->SetTextData(pValue->ToWideString()); | 3460 pXMLElement->SetTextData(pValue->ToWideString()); |
3420 } | 3461 } |
3421 } else { | 3462 } else { |
3422 CFX_WideString wsTextData; | 3463 CFX_WideString wsTextData; |
3423 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3464 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3424 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3465 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3425 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3466 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3426 pXMLElement->GetTextData(wsTextData); | 3467 pXMLElement->GetTextData(wsTextData); |
3427 } | 3468 } |
3428 pValue->SetString( | 3469 pValue->SetString( |
3429 FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC()); | 3470 FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC()); |
3430 } | 3471 } |
3431 } | 3472 } |
| 3473 |
3432 void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { | 3474 void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { |
3433 int32_t argc = pArguments->GetLength(); | 3475 int32_t argc = pArguments->GetLength(); |
3434 if (argc == 0) { | 3476 if (argc == 0) { |
3435 } else { | 3477 } else { |
3436 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); | 3478 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); |
3437 } | 3479 } |
3438 } | 3480 } |
| 3481 |
3439 void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { | 3482 void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { |
3440 int32_t argc = pArguments->GetLength(); | 3483 int32_t argc = pArguments->GetLength(); |
3441 if (argc == 0) { | 3484 if (argc == 0) { |
3442 } else { | 3485 } else { |
3443 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancelBatch"); | 3486 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancelBatch"); |
3444 } | 3487 } |
3445 } | 3488 } |
| 3489 |
3446 void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { | 3490 void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { |
3447 int32_t argc = pArguments->GetLength(); | 3491 int32_t argc = pArguments->GetLength(); |
3448 if (argc == 0) { | 3492 if (argc == 0) { |
3449 } else { | 3493 } else { |
3450 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"first"); | 3494 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"first"); |
3451 } | 3495 } |
3452 } | 3496 } |
| 3497 |
3453 void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { | 3498 void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { |
3454 int32_t argc = pArguments->GetLength(); | 3499 int32_t argc = pArguments->GetLength(); |
3455 if (argc == 0) { | 3500 if (argc == 0) { |
3456 } else { | 3501 } else { |
3457 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"updateBatch"); | 3502 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"updateBatch"); |
3458 } | 3503 } |
3459 } | 3504 } |
| 3505 |
3460 void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { | 3506 void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { |
3461 int32_t argc = pArguments->GetLength(); | 3507 int32_t argc = pArguments->GetLength(); |
3462 if (argc == 0) { | 3508 if (argc == 0) { |
3463 } else { | 3509 } else { |
3464 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"previous"); | 3510 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"previous"); |
3465 } | 3511 } |
3466 } | 3512 } |
| 3513 |
3467 void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { | 3514 void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { |
3468 int32_t argc = pArguments->GetLength(); | 3515 int32_t argc = pArguments->GetLength(); |
3469 if (argc == 0) { | 3516 if (argc == 0) { |
3470 } else { | 3517 } else { |
3471 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isBOF"); | 3518 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isBOF"); |
3472 } | 3519 } |
3473 } | 3520 } |
| 3521 |
3474 void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { | 3522 void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { |
3475 int32_t argc = pArguments->GetLength(); | 3523 int32_t argc = pArguments->GetLength(); |
3476 if (argc == 0) { | 3524 if (argc == 0) { |
3477 } else { | 3525 } else { |
3478 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isEOF"); | 3526 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isEOF"); |
3479 } | 3527 } |
3480 } | 3528 } |
| 3529 |
3481 void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { | 3530 void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { |
3482 int32_t argc = pArguments->GetLength(); | 3531 int32_t argc = pArguments->GetLength(); |
3483 if (argc == 0) { | 3532 if (argc == 0) { |
3484 } else { | 3533 } else { |
3485 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancel"); | 3534 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancel"); |
3486 } | 3535 } |
3487 } | 3536 } |
| 3537 |
3488 void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { | 3538 void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { |
3489 int32_t argc = pArguments->GetLength(); | 3539 int32_t argc = pArguments->GetLength(); |
3490 if (argc == 0) { | 3540 if (argc == 0) { |
3491 } else { | 3541 } else { |
3492 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"update"); | 3542 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"update"); |
3493 } | 3543 } |
3494 } | 3544 } |
| 3545 |
3495 void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { | 3546 void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { |
3496 int32_t argc = pArguments->GetLength(); | 3547 int32_t argc = pArguments->GetLength(); |
3497 if (argc == 0) { | 3548 if (argc == 0) { |
3498 } else { | 3549 } else { |
3499 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"open"); | 3550 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"open"); |
3500 } | 3551 } |
3501 } | 3552 } |
| 3553 |
3502 void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { | 3554 void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { |
3503 int32_t argc = pArguments->GetLength(); | 3555 int32_t argc = pArguments->GetLength(); |
3504 if (argc == 0) { | 3556 if (argc == 0) { |
3505 } else { | 3557 } else { |
3506 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"delete"); | 3558 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"delete"); |
3507 } | 3559 } |
3508 } | 3560 } |
| 3561 |
3509 void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { | 3562 void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { |
3510 int32_t argc = pArguments->GetLength(); | 3563 int32_t argc = pArguments->GetLength(); |
3511 if (argc == 0) { | 3564 if (argc == 0) { |
3512 } else { | 3565 } else { |
3513 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addNew"); | 3566 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addNew"); |
3514 } | 3567 } |
3515 } | 3568 } |
| 3569 |
3516 void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { | 3570 void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { |
3517 int32_t argc = pArguments->GetLength(); | 3571 int32_t argc = pArguments->GetLength(); |
3518 if (argc == 0) { | 3572 if (argc == 0) { |
3519 } else { | 3573 } else { |
3520 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"requery"); | 3574 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"requery"); |
3521 } | 3575 } |
3522 } | 3576 } |
| 3577 |
3523 void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { | 3578 void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { |
3524 int32_t argc = pArguments->GetLength(); | 3579 int32_t argc = pArguments->GetLength(); |
3525 if (argc == 0) { | 3580 if (argc == 0) { |
3526 } else { | 3581 } else { |
3527 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resync"); | 3582 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resync"); |
3528 } | 3583 } |
3529 } | 3584 } |
| 3585 |
3530 void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { | 3586 void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { |
3531 int32_t argc = pArguments->GetLength(); | 3587 int32_t argc = pArguments->GetLength(); |
3532 if (argc == 0) { | 3588 if (argc == 0) { |
3533 } else { | 3589 } else { |
3534 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"close"); | 3590 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"close"); |
3535 } | 3591 } |
3536 } | 3592 } |
| 3593 |
3537 void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { | 3594 void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { |
3538 int32_t argc = pArguments->GetLength(); | 3595 int32_t argc = pArguments->GetLength(); |
3539 if (argc == 0) { | 3596 if (argc == 0) { |
3540 } else { | 3597 } else { |
3541 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"last"); | 3598 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"last"); |
3542 } | 3599 } |
3543 } | 3600 } |
| 3601 |
3544 void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { | 3602 void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { |
3545 int32_t argc = pArguments->GetLength(); | 3603 int32_t argc = pArguments->GetLength(); |
3546 if (argc == 0) { | 3604 if (argc == 0) { |
3547 } else { | 3605 } else { |
3548 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"hasDataChanged"); | 3606 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"hasDataChanged"); |
3549 } | 3607 } |
3550 } | 3608 } |
| 3609 |
3551 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, | 3610 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, |
3552 FX_BOOL bSetting, | 3611 FX_BOOL bSetting, |
3553 XFA_ATTRIBUTE eAttribute) {} | 3612 XFA_ATTRIBUTE eAttribute) {} |
| 3613 |
3554 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, | 3614 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, |
3555 FX_BOOL bSetting, | 3615 FX_BOOL bSetting, |
3556 XFA_ATTRIBUTE eAttribute) { | 3616 XFA_ATTRIBUTE eAttribute) { |
3557 if (!bSetting) { | 3617 if (!bSetting) { |
3558 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); | 3618 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); |
3559 ASSERT(pThis); | 3619 ASSERT(pThis); |
3560 pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); | 3620 pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); |
3561 } | 3621 } |
3562 } | 3622 } |
| 3623 |
3563 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, | 3624 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, |
3564 FX_BOOL bSetting, | 3625 FX_BOOL bSetting, |
3565 XFA_ATTRIBUTE eAttribute) {} | 3626 XFA_ATTRIBUTE eAttribute) {} |
| 3627 |
3566 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, | 3628 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, |
3567 FX_BOOL bSetting, | 3629 FX_BOOL bSetting, |
3568 XFA_ATTRIBUTE eAttribute) {} | 3630 XFA_ATTRIBUTE eAttribute) {} |
| 3631 |
3569 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, | 3632 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, |
3570 FX_BOOL bSetting, | 3633 FX_BOOL bSetting, |
3571 XFA_ATTRIBUTE eAttribute) {} | 3634 XFA_ATTRIBUTE eAttribute) {} |
| 3635 |
3572 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, | 3636 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, |
3573 FX_BOOL bSetting, | 3637 FX_BOOL bSetting, |
3574 XFA_ATTRIBUTE eAttribute) { | 3638 XFA_ATTRIBUTE eAttribute) { |
3575 if (bSetting) { | 3639 if (bSetting) { |
3576 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 3640 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
3577 return; | 3641 return; |
3578 } | 3642 } |
3579 pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC()); | 3643 pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC()); |
3580 } | 3644 } |
| 3645 |
3581 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, | 3646 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, |
3582 FX_BOOL bSetting, | 3647 FX_BOOL bSetting, |
3583 XFA_ATTRIBUTE eAttribute) {} | 3648 XFA_ATTRIBUTE eAttribute) {} |
3584 enum XFA_KEYTYPE { | 3649 |
3585 XFA_KEYTYPE_Custom, | |
3586 XFA_KEYTYPE_Element, | |
3587 }; | |
3588 void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { | |
3589 uint32_t dwKey = FX_HashCode_GetW(wsKey, false); | |
3590 return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); | |
3591 } | |
3592 void* XFA_GetMapKey_Element(XFA_Element eType, XFA_ATTRIBUTE eAttribute) { | |
3593 return (void*)(uintptr_t)((static_cast<int32_t>(eType) << 16) | | |
3594 (eAttribute << 8) | XFA_KEYTYPE_Element); | |
3595 } | |
3596 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { | 3650 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { |
3597 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 3651 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3598 return HasMapModuleKey(pKey, bCanInherit); | 3652 return HasMapModuleKey(pKey, bCanInherit); |
3599 } | 3653 } |
| 3654 |
3600 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, | 3655 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, |
3601 const CFX_WideStringC& wsValue, | 3656 const CFX_WideStringC& wsValue, |
3602 bool bNotify) { | 3657 bool bNotify) { |
3603 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); | 3658 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); |
3604 if (!pAttr) | 3659 if (!pAttr) |
3605 return FALSE; | 3660 return FALSE; |
3606 | 3661 |
3607 XFA_ATTRIBUTETYPE eType = pAttr->eType; | 3662 XFA_ATTRIBUTETYPE eType = pAttr->eType; |
3608 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { | 3663 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { |
3609 const XFA_NOTSUREATTRIBUTE* pNotsure = | 3664 const XFA_NOTSUREATTRIBUTE* pNotsure = |
(...skipping 17 matching lines...) Expand all Loading... |
3627 pAttr->eName, | 3682 pAttr->eName, |
3628 FXSYS_round(FX_wcstof(wsValue.c_str(), wsValue.GetLength(), nullptr)), | 3683 FXSYS_round(FX_wcstof(wsValue.c_str(), wsValue.GetLength(), nullptr)), |
3629 bNotify); | 3684 bNotify); |
3630 case XFA_ATTRIBUTETYPE_Measure: | 3685 case XFA_ATTRIBUTETYPE_Measure: |
3631 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); | 3686 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); |
3632 default: | 3687 default: |
3633 break; | 3688 break; |
3634 } | 3689 } |
3635 return FALSE; | 3690 return FALSE; |
3636 } | 3691 } |
| 3692 |
3637 FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, | 3693 FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, |
3638 CFX_WideString& wsValue, | 3694 CFX_WideString& wsValue, |
3639 FX_BOOL bUseDefault) { | 3695 FX_BOOL bUseDefault) { |
3640 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); | 3696 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); |
3641 if (!pAttr) { | 3697 if (!pAttr) { |
3642 return FALSE; | 3698 return FALSE; |
3643 } | 3699 } |
3644 XFA_ATTRIBUTETYPE eType = pAttr->eType; | 3700 XFA_ATTRIBUTETYPE eType = pAttr->eType; |
3645 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { | 3701 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { |
3646 const XFA_NOTSUREATTRIBUTE* pNotsure = | 3702 const XFA_NOTSUREATTRIBUTE* pNotsure = |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3686 return FALSE; | 3742 return FALSE; |
3687 } | 3743 } |
3688 mValue.ToString(wsValue); | 3744 mValue.ToString(wsValue); |
3689 return TRUE; | 3745 return TRUE; |
3690 } break; | 3746 } break; |
3691 default: | 3747 default: |
3692 break; | 3748 break; |
3693 } | 3749 } |
3694 return FALSE; | 3750 return FALSE; |
3695 } | 3751 } |
| 3752 |
3696 FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, | 3753 FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, |
3697 const CFX_WideStringC& wsValue, | 3754 const CFX_WideStringC& wsValue, |
3698 bool bNotify) { | 3755 bool bNotify) { |
3699 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); | 3756 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); |
3700 if (pAttributeInfo) { | 3757 if (pAttributeInfo) { |
3701 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); | 3758 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); |
3702 } | 3759 } |
3703 void* pKey = XFA_GetMapKey_Custom(wsAttr); | 3760 void* pKey = GetMapKey_Custom(wsAttr); |
3704 SetMapModuleString(pKey, wsValue); | 3761 SetMapModuleString(pKey, wsValue); |
3705 return TRUE; | 3762 return TRUE; |
3706 } | 3763 } |
| 3764 |
3707 FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, | 3765 FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, |
3708 CFX_WideString& wsValue, | 3766 CFX_WideString& wsValue, |
3709 FX_BOOL bUseDefault) { | 3767 FX_BOOL bUseDefault) { |
3710 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr); | 3768 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr); |
3711 if (pAttributeInfo) { | 3769 if (pAttributeInfo) { |
3712 return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault); | 3770 return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault); |
3713 } | 3771 } |
3714 void* pKey = XFA_GetMapKey_Custom(wsAttr); | 3772 void* pKey = GetMapKey_Custom(wsAttr); |
3715 CFX_WideStringC wsValueC; | 3773 CFX_WideStringC wsValueC; |
3716 if (GetMapModuleString(pKey, wsValueC)) { | 3774 if (GetMapModuleString(pKey, wsValueC)) { |
3717 wsValue = wsValueC; | 3775 wsValue = wsValueC; |
3718 } | 3776 } |
3719 return TRUE; | 3777 return TRUE; |
3720 } | 3778 } |
| 3779 |
3721 FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { | 3780 FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { |
3722 void* pKey = XFA_GetMapKey_Custom(wsAttr); | 3781 void* pKey = GetMapKey_Custom(wsAttr); |
3723 RemoveMapModuleKey(pKey); | 3782 RemoveMapModuleKey(pKey); |
3724 return TRUE; | 3783 return TRUE; |
3725 } | 3784 } |
| 3785 |
3726 FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, | 3786 FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, |
3727 FX_BOOL& bValue, | 3787 FX_BOOL& bValue, |
3728 FX_BOOL bUseDefault) { | 3788 FX_BOOL bUseDefault) { |
3729 void* pValue = nullptr; | 3789 void* pValue = nullptr; |
3730 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) | 3790 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) |
3731 return FALSE; | 3791 return FALSE; |
3732 bValue = (FX_BOOL)(uintptr_t)pValue; | 3792 bValue = (FX_BOOL)(uintptr_t)pValue; |
3733 return TRUE; | 3793 return TRUE; |
3734 } | 3794 } |
| 3795 |
3735 FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, | 3796 FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, |
3736 int32_t& iValue, | 3797 int32_t& iValue, |
3737 FX_BOOL bUseDefault) { | 3798 FX_BOOL bUseDefault) { |
3738 void* pValue = nullptr; | 3799 void* pValue = nullptr; |
3739 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) | 3800 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) |
3740 return FALSE; | 3801 return FALSE; |
3741 iValue = (int32_t)(uintptr_t)pValue; | 3802 iValue = (int32_t)(uintptr_t)pValue; |
3742 return TRUE; | 3803 return TRUE; |
3743 } | 3804 } |
| 3805 |
3744 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, | 3806 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, |
3745 XFA_ATTRIBUTEENUM& eValue, | 3807 XFA_ATTRIBUTEENUM& eValue, |
3746 FX_BOOL bUseDefault) { | 3808 FX_BOOL bUseDefault) { |
3747 void* pValue = nullptr; | 3809 void* pValue = nullptr; |
3748 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) | 3810 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) |
3749 return FALSE; | 3811 return FALSE; |
3750 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; | 3812 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; |
3751 return TRUE; | 3813 return TRUE; |
3752 } | 3814 } |
3753 | 3815 |
3754 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, | 3816 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, |
3755 CXFA_Measurement mValue, | 3817 CXFA_Measurement mValue, |
3756 bool bNotify) { | 3818 bool bNotify) { |
3757 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 3819 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3758 OnChanging(eAttr, bNotify); | 3820 OnChanging(eAttr, bNotify); |
3759 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); | 3821 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); |
3760 OnChanged(eAttr, bNotify, FALSE); | 3822 OnChanged(eAttr, bNotify, FALSE); |
3761 return TRUE; | 3823 return TRUE; |
3762 } | 3824 } |
3763 | 3825 |
3764 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, | 3826 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, |
3765 CXFA_Measurement& mValue, | 3827 CXFA_Measurement& mValue, |
3766 FX_BOOL bUseDefault) const { | 3828 FX_BOOL bUseDefault) const { |
3767 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 3829 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3768 void* pValue; | 3830 void* pValue; |
3769 int32_t iBytes; | 3831 int32_t iBytes; |
3770 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { | 3832 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { |
3771 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); | 3833 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); |
3772 return TRUE; | 3834 return TRUE; |
3773 } | 3835 } |
3774 if (bUseDefault && | 3836 if (bUseDefault && |
3775 XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, | 3837 XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, |
3776 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { | 3838 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { |
3777 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); | 3839 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); |
3778 return TRUE; | 3840 return TRUE; |
3779 } | 3841 } |
3780 return FALSE; | 3842 return FALSE; |
3781 } | 3843 } |
3782 | 3844 |
3783 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { | 3845 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { |
3784 CXFA_Measurement mValue; | 3846 CXFA_Measurement mValue; |
3785 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); | 3847 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); |
3786 } | 3848 } |
3787 | 3849 |
3788 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, | 3850 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, |
3789 const CFX_WideString& wsValue, | 3851 const CFX_WideString& wsValue, |
3790 bool bNotify, | 3852 bool bNotify, |
3791 FX_BOOL bScriptModify) { | 3853 FX_BOOL bScriptModify) { |
3792 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 3854 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3793 OnChanging(eAttr, bNotify); | 3855 OnChanging(eAttr, bNotify); |
3794 if (eAttr == XFA_ATTRIBUTE_Value) { | 3856 if (eAttr == XFA_ATTRIBUTE_Value) { |
3795 CFX_WideString* pClone = new CFX_WideString(wsValue); | 3857 CFX_WideString* pClone = new CFX_WideString(wsValue); |
3796 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 3858 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
3797 } else { | 3859 } else { |
3798 SetMapModuleString(pKey, wsValue.AsStringC()); | 3860 SetMapModuleString(pKey, wsValue.AsStringC()); |
3799 if (eAttr == XFA_ATTRIBUTE_Name) | 3861 if (eAttr == XFA_ATTRIBUTE_Name) |
3800 UpdateNameHash(); | 3862 UpdateNameHash(); |
3801 } | 3863 } |
3802 OnChanged(eAttr, bNotify, bScriptModify); | 3864 OnChanged(eAttr, bNotify, bScriptModify); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3858 } | 3920 } |
3859 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); | 3921 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); |
3860 } | 3922 } |
3861 return TRUE; | 3923 return TRUE; |
3862 } | 3924 } |
3863 | 3925 |
3864 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, | 3926 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, |
3865 const CFX_WideString& wsXMLValue, | 3927 const CFX_WideString& wsXMLValue, |
3866 bool bNotify, | 3928 bool bNotify, |
3867 FX_BOOL bScriptModify) { | 3929 FX_BOOL bScriptModify) { |
3868 void* pKey = XFA_GetMapKey_Element(GetElementType(), XFA_ATTRIBUTE_Value); | 3930 void* pKey = GetMapKey_Element(GetElementType(), XFA_ATTRIBUTE_Value); |
3869 OnChanging(XFA_ATTRIBUTE_Value, bNotify); | 3931 OnChanging(XFA_ATTRIBUTE_Value, bNotify); |
3870 CFX_WideString* pClone = new CFX_WideString(wsValue); | 3932 CFX_WideString* pClone = new CFX_WideString(wsValue); |
3871 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 3933 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
3872 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); | 3934 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); |
3873 if (IsNeedSavingXMLNode()) { | 3935 if (IsNeedSavingXMLNode()) { |
3874 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); | 3936 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
3875 switch (eXMLType) { | 3937 switch (eXMLType) { |
3876 case FDE_XMLNODE_Element: | 3938 case FDE_XMLNODE_Element: |
3877 if (IsAttributeInXML()) { | 3939 if (IsAttributeInXML()) { |
3878 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 3940 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
(...skipping 21 matching lines...) Expand all Loading... |
3900 break; | 3962 break; |
3901 case FDE_XMLNODE_Text: | 3963 case FDE_XMLNODE_Text: |
3902 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsXMLValue); | 3964 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsXMLValue); |
3903 break; | 3965 break; |
3904 default: | 3966 default: |
3905 ASSERT(0); | 3967 ASSERT(0); |
3906 } | 3968 } |
3907 } | 3969 } |
3908 return TRUE; | 3970 return TRUE; |
3909 } | 3971 } |
| 3972 |
3910 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, | 3973 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, |
3911 CFX_WideString& wsValue, | 3974 CFX_WideString& wsValue, |
3912 FX_BOOL bUseDefault, | 3975 FX_BOOL bUseDefault, |
3913 FX_BOOL bProto) { | 3976 FX_BOOL bProto) { |
3914 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 3977 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3915 if (eAttr == XFA_ATTRIBUTE_Value) { | 3978 if (eAttr == XFA_ATTRIBUTE_Value) { |
3916 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); | 3979 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); |
3917 if (pStr) { | 3980 if (pStr) { |
3918 wsValue = *pStr; | 3981 wsValue = *pStr; |
3919 return TRUE; | 3982 return TRUE; |
3920 } | 3983 } |
3921 } else { | 3984 } else { |
3922 CFX_WideStringC wsValueC; | 3985 CFX_WideStringC wsValueC; |
3923 if (GetMapModuleString(pKey, wsValueC)) { | 3986 if (GetMapModuleString(pKey, wsValueC)) { |
3924 wsValue = wsValueC; | 3987 wsValue = wsValueC; |
3925 return TRUE; | 3988 return TRUE; |
3926 } | 3989 } |
3927 } | 3990 } |
3928 if (!bUseDefault) { | 3991 if (!bUseDefault) { |
3929 return FALSE; | 3992 return FALSE; |
3930 } | 3993 } |
3931 void* pValue = nullptr; | 3994 void* pValue = nullptr; |
3932 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, | 3995 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, |
3933 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { | 3996 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { |
3934 wsValue = (const FX_WCHAR*)pValue; | 3997 wsValue = (const FX_WCHAR*)pValue; |
3935 return TRUE; | 3998 return TRUE; |
3936 } | 3999 } |
3937 return FALSE; | 4000 return FALSE; |
3938 } | 4001 } |
| 4002 |
3939 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, | 4003 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, |
3940 CFX_WideStringC& wsValue, | 4004 CFX_WideStringC& wsValue, |
3941 FX_BOOL bUseDefault, | 4005 FX_BOOL bUseDefault, |
3942 FX_BOOL bProto) { | 4006 FX_BOOL bProto) { |
3943 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 4007 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3944 if (eAttr == XFA_ATTRIBUTE_Value) { | 4008 if (eAttr == XFA_ATTRIBUTE_Value) { |
3945 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); | 4009 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); |
3946 if (pStr) { | 4010 if (pStr) { |
3947 wsValue = pStr->AsStringC(); | 4011 wsValue = pStr->AsStringC(); |
3948 return TRUE; | 4012 return TRUE; |
3949 } | 4013 } |
3950 } else { | 4014 } else { |
3951 if (GetMapModuleString(pKey, wsValue)) { | 4015 if (GetMapModuleString(pKey, wsValue)) { |
3952 return TRUE; | 4016 return TRUE; |
3953 } | 4017 } |
3954 } | 4018 } |
3955 if (!bUseDefault) { | 4019 if (!bUseDefault) { |
3956 return FALSE; | 4020 return FALSE; |
3957 } | 4021 } |
3958 void* pValue = nullptr; | 4022 void* pValue = nullptr; |
3959 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, | 4023 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, |
3960 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { | 4024 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { |
3961 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; | 4025 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; |
3962 return TRUE; | 4026 return TRUE; |
3963 } | 4027 } |
3964 return FALSE; | 4028 return FALSE; |
3965 } | 4029 } |
| 4030 |
3966 FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, | 4031 FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, |
3967 void* pData, | 4032 void* pData, |
3968 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4033 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
3969 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 4034 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3970 return SetUserData(pKey, pData, pCallbackInfo); | 4035 return SetUserData(pKey, pData, pCallbackInfo); |
3971 } | 4036 } |
| 4037 |
3972 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { | 4038 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { |
3973 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 4039 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3974 pData = GetUserData(pKey); | 4040 pData = GetUserData(pKey); |
3975 return !!pData; | 4041 return !!pData; |
3976 } | 4042 } |
| 4043 |
3977 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, | 4044 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, |
3978 XFA_ATTRIBUTETYPE eType, | 4045 XFA_ATTRIBUTETYPE eType, |
3979 void* pValue, | 4046 void* pValue, |
3980 bool bNotify) { | 4047 bool bNotify) { |
3981 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 4048 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
3982 OnChanging(eAttr, bNotify); | 4049 OnChanging(eAttr, bNotify); |
3983 SetMapModuleValue(pKey, pValue); | 4050 SetMapModuleValue(pKey, pValue); |
3984 OnChanged(eAttr, bNotify, FALSE); | 4051 OnChanged(eAttr, bNotify, FALSE); |
3985 if (IsNeedSavingXMLNode()) { | 4052 if (IsNeedSavingXMLNode()) { |
3986 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 4053 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
3987 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); | 4054 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); |
3988 if (pInfo) { | 4055 if (pInfo) { |
3989 switch (eType) { | 4056 switch (eType) { |
3990 case XFA_ATTRIBUTETYPE_Enum: | 4057 case XFA_ATTRIBUTETYPE_Enum: |
3991 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4058 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
(...skipping 10 matching lines...) Expand all Loading... |
4002 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4069 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
4003 ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); | 4070 ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); |
4004 break; | 4071 break; |
4005 default: | 4072 default: |
4006 ASSERT(0); | 4073 ASSERT(0); |
4007 } | 4074 } |
4008 } | 4075 } |
4009 } | 4076 } |
4010 return TRUE; | 4077 return TRUE; |
4011 } | 4078 } |
| 4079 |
4012 FX_BOOL CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr, | 4080 FX_BOOL CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr, |
4013 XFA_ATTRIBUTETYPE eType, | 4081 XFA_ATTRIBUTETYPE eType, |
4014 FX_BOOL bUseDefault, | 4082 FX_BOOL bUseDefault, |
4015 void*& pValue) { | 4083 void*& pValue) { |
4016 void* pKey = XFA_GetMapKey_Element(GetElementType(), eAttr); | 4084 void* pKey = GetMapKey_Element(GetElementType(), eAttr); |
4017 if (GetMapModuleValue(pKey, pValue)) { | 4085 if (GetMapModuleValue(pKey, pValue)) { |
4018 return TRUE; | 4086 return TRUE; |
4019 } | 4087 } |
4020 if (!bUseDefault) { | 4088 if (!bUseDefault) { |
4021 return FALSE; | 4089 return FALSE; |
4022 } | 4090 } |
4023 return XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, eType, | 4091 return XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, eType, |
4024 m_ePacket); | 4092 m_ePacket); |
4025 } | 4093 } |
4026 static void XFA_DefaultFreeData(void* pData) {} | 4094 |
4027 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { | |
4028 XFA_DefaultFreeData, nullptr}; | |
4029 FX_BOOL CXFA_Node::SetUserData(void* pKey, | 4095 FX_BOOL CXFA_Node::SetUserData(void* pKey, |
4030 void* pData, | 4096 void* pData, |
4031 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4097 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
4032 SetMapModuleBuffer(pKey, &pData, sizeof(void*), | 4098 SetMapModuleBuffer(pKey, &pData, sizeof(void*), |
4033 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); | 4099 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); |
4034 return TRUE; | 4100 return TRUE; |
4035 } | 4101 } |
| 4102 |
4036 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { | 4103 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { |
4037 int32_t iBytes = 0; | 4104 int32_t iBytes = 0; |
4038 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { | 4105 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { |
4039 return FALSE; | 4106 return FALSE; |
4040 } | 4107 } |
4041 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); | 4108 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); |
4042 } | 4109 } |
| 4110 |
4043 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, | 4111 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, |
4044 const CFX_WideString& wsXMLValue, | 4112 const CFX_WideString& wsXMLValue, |
4045 bool bNotify, | 4113 bool bNotify, |
4046 FX_BOOL bScriptModify, | 4114 FX_BOOL bScriptModify, |
4047 FX_BOOL bSyncData) { | 4115 FX_BOOL bSyncData) { |
4048 CXFA_Node* pNode = nullptr; | 4116 CXFA_Node* pNode = nullptr; |
4049 CXFA_Node* pBindNode = nullptr; | 4117 CXFA_Node* pBindNode = nullptr; |
4050 switch (GetObjectType()) { | 4118 switch (GetObjectType()) { |
4051 case XFA_ObjectType::ContainerNode: { | 4119 case XFA_ObjectType::ContainerNode: { |
4052 if (XFA_FieldIsMultiListBox(this)) { | 4120 if (XFA_FieldIsMultiListBox(this)) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4205 pBindNode->GetBindItems(nodeArray); | 4273 pBindNode->GetBindItems(nodeArray); |
4206 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { | 4274 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { |
4207 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, | 4275 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, |
4208 bScriptModify, FALSE); | 4276 bScriptModify, FALSE); |
4209 } | 4277 } |
4210 } | 4278 } |
4211 return TRUE; | 4279 return TRUE; |
4212 } | 4280 } |
4213 return FALSE; | 4281 return FALSE; |
4214 } | 4282 } |
| 4283 |
4215 FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, | 4284 FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, |
4216 const CFX_WideString& wsXMLValue, | 4285 const CFX_WideString& wsXMLValue, |
4217 bool bNotify, | 4286 bool bNotify, |
4218 FX_BOOL bScriptModify, | 4287 FX_BOOL bScriptModify, |
4219 FX_BOOL bSyncData) { | 4288 FX_BOOL bSyncData) { |
4220 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, | 4289 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, |
4221 bSyncData); | 4290 bSyncData); |
4222 } | 4291 } |
| 4292 |
4223 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { | 4293 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { |
4224 CFX_WideString wsContent; | 4294 CFX_WideString wsContent; |
4225 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); | 4295 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); |
4226 } | 4296 } |
| 4297 |
4227 CFX_WideString CXFA_Node::GetContent() { | 4298 CFX_WideString CXFA_Node::GetContent() { |
4228 return GetScriptContent(); | 4299 return GetScriptContent(); |
4229 } | 4300 } |
| 4301 |
4230 FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, | 4302 FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, |
4231 FX_BOOL bScriptModify, | 4303 FX_BOOL bScriptModify, |
4232 FX_BOOL bProto) { | 4304 FX_BOOL bProto) { |
4233 CXFA_Node* pNode = nullptr; | 4305 CXFA_Node* pNode = nullptr; |
4234 switch (GetObjectType()) { | 4306 switch (GetObjectType()) { |
4235 case XFA_ObjectType::ContainerNode: | 4307 case XFA_ObjectType::ContainerNode: |
4236 if (GetElementType() == XFA_Element::ExclGroup) { | 4308 if (GetElementType() == XFA_Element::ExclGroup) { |
4237 pNode = this; | 4309 pNode = this; |
4238 } else { | 4310 } else { |
4239 CXFA_Node* pValue = GetChild(0, XFA_Element::Value); | 4311 CXFA_Node* pValue = GetChild(0, XFA_Element::Value); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 if (bScriptModify) { | 4354 if (bScriptModify) { |
4283 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4355 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
4284 if (pScriptContext) { | 4356 if (pScriptContext) { |
4285 m_pDocument->GetScriptContext()->AddNodesOfRunScript(this); | 4357 m_pDocument->GetScriptContext()->AddNodesOfRunScript(this); |
4286 } | 4358 } |
4287 } | 4359 } |
4288 return TryCData(XFA_ATTRIBUTE_Value, wsContent, FALSE, bProto); | 4360 return TryCData(XFA_ATTRIBUTE_Value, wsContent, FALSE, bProto); |
4289 } | 4361 } |
4290 return FALSE; | 4362 return FALSE; |
4291 } | 4363 } |
| 4364 |
4292 CXFA_Node* CXFA_Node::GetModelNode() { | 4365 CXFA_Node* CXFA_Node::GetModelNode() { |
4293 switch (GetPacketID()) { | 4366 switch (GetPacketID()) { |
4294 case XFA_XDPPACKET_XDP: | 4367 case XFA_XDPPACKET_XDP: |
4295 return m_pDocument->GetRoot(); | 4368 return m_pDocument->GetRoot(); |
4296 case XFA_XDPPACKET_Config: | 4369 case XFA_XDPPACKET_Config: |
4297 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); | 4370 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); |
4298 case XFA_XDPPACKET_Template: | 4371 case XFA_XDPPACKET_Template: |
4299 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); | 4372 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); |
4300 case XFA_XDPPACKET_Form: | 4373 case XFA_XDPPACKET_Form: |
4301 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); | 4374 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); |
4302 case XFA_XDPPACKET_Datasets: | 4375 case XFA_XDPPACKET_Datasets: |
4303 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); | 4376 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); |
4304 case XFA_XDPPACKET_LocaleSet: | 4377 case XFA_XDPPACKET_LocaleSet: |
4305 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet)); | 4378 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet)); |
4306 case XFA_XDPPACKET_ConnectionSet: | 4379 case XFA_XDPPACKET_ConnectionSet: |
4307 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet)); | 4380 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet)); |
4308 case XFA_XDPPACKET_SourceSet: | 4381 case XFA_XDPPACKET_SourceSet: |
4309 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet)); | 4382 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet)); |
4310 case XFA_XDPPACKET_Xdc: | 4383 case XFA_XDPPACKET_Xdc: |
4311 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc)); | 4384 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc)); |
4312 default: | 4385 default: |
4313 return this; | 4386 return this; |
4314 } | 4387 } |
4315 } | 4388 } |
| 4389 |
4316 FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { | 4390 FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { |
4317 wsNamespace.clear(); | 4391 wsNamespace.clear(); |
4318 if (IsModelNode() || GetElementType() == XFA_Element::Packet) { | 4392 if (IsModelNode() || GetElementType() == XFA_Element::Packet) { |
4319 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 4393 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
4320 if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { | 4394 if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { |
4321 return FALSE; | 4395 return FALSE; |
4322 } | 4396 } |
4323 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); | 4397 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); |
4324 return TRUE; | 4398 return TRUE; |
4325 } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 4399 } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
(...skipping 10 matching lines...) Expand all Loading... |
4336 static_cast<CFDE_XMLElement*>(pXMLNode), | 4410 static_cast<CFDE_XMLElement*>(pXMLNode), |
4337 GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace); | 4411 GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace); |
4338 } | 4412 } |
4339 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); | 4413 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); |
4340 return TRUE; | 4414 return TRUE; |
4341 } else { | 4415 } else { |
4342 CXFA_Node* pModelNode = GetModelNode(); | 4416 CXFA_Node* pModelNode = GetModelNode(); |
4343 return pModelNode->TryNamespace(wsNamespace); | 4417 return pModelNode->TryNamespace(wsNamespace); |
4344 } | 4418 } |
4345 } | 4419 } |
| 4420 |
4346 CXFA_Node* CXFA_Node::GetProperty(int32_t index, | 4421 CXFA_Node* CXFA_Node::GetProperty(int32_t index, |
4347 XFA_Element eProperty, | 4422 XFA_Element eProperty, |
4348 FX_BOOL bCreateProperty) { | 4423 FX_BOOL bCreateProperty) { |
4349 XFA_Element eType = GetElementType(); | 4424 XFA_Element eType = GetElementType(); |
4350 uint32_t dwPacket = GetPacketID(); | 4425 uint32_t dwPacket = GetPacketID(); |
4351 const XFA_PROPERTY* pProperty = | 4426 const XFA_PROPERTY* pProperty = |
4352 XFA_GetPropertyOfElement(eType, eProperty, dwPacket); | 4427 XFA_GetPropertyOfElement(eType, eProperty, dwPacket); |
4353 if (!pProperty || index >= pProperty->uOccur) | 4428 if (!pProperty || index >= pProperty->uOccur) |
4354 return nullptr; | 4429 return nullptr; |
4355 | 4430 |
(...skipping 24 matching lines...) Expand all Loading... |
4380 CXFA_Node* pNewNode = nullptr; | 4455 CXFA_Node* pNewNode = nullptr; |
4381 for (; iCount <= index; iCount++) { | 4456 for (; iCount <= index; iCount++) { |
4382 pNewNode = m_pDocument->CreateNode(pPacket, eProperty); | 4457 pNewNode = m_pDocument->CreateNode(pPacket, eProperty); |
4383 if (!pNewNode) | 4458 if (!pNewNode) |
4384 return nullptr; | 4459 return nullptr; |
4385 InsertChild(pNewNode, nullptr); | 4460 InsertChild(pNewNode, nullptr); |
4386 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); | 4461 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); |
4387 } | 4462 } |
4388 return pNewNode; | 4463 return pNewNode; |
4389 } | 4464 } |
| 4465 |
4390 int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) { | 4466 int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) { |
4391 CXFA_Node* pNode = m_pChild; | 4467 CXFA_Node* pNode = m_pChild; |
4392 int32_t iCount = 0; | 4468 int32_t iCount = 0; |
4393 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4469 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4394 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { | 4470 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { |
4395 if (bOnlyChild) { | 4471 if (bOnlyChild) { |
4396 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( | 4472 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( |
4397 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); | 4473 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); |
4398 if (pProperty) { | 4474 if (pProperty) { |
4399 continue; | 4475 continue; |
4400 } | 4476 } |
4401 } | 4477 } |
4402 iCount++; | 4478 iCount++; |
4403 } | 4479 } |
4404 } | 4480 } |
4405 return iCount; | 4481 return iCount; |
4406 } | 4482 } |
| 4483 |
4407 CXFA_Node* CXFA_Node::GetChild(int32_t index, | 4484 CXFA_Node* CXFA_Node::GetChild(int32_t index, |
4408 XFA_Element eType, | 4485 XFA_Element eType, |
4409 FX_BOOL bOnlyChild) { | 4486 FX_BOOL bOnlyChild) { |
4410 ASSERT(index > -1); | 4487 ASSERT(index > -1); |
4411 CXFA_Node* pNode = m_pChild; | 4488 CXFA_Node* pNode = m_pChild; |
4412 int32_t iCount = 0; | 4489 int32_t iCount = 0; |
4413 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4490 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4414 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { | 4491 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { |
4415 if (bOnlyChild) { | 4492 if (bOnlyChild) { |
4416 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( | 4493 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( |
4417 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); | 4494 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); |
4418 if (pProperty) { | 4495 if (pProperty) { |
4419 continue; | 4496 continue; |
4420 } | 4497 } |
4421 } | 4498 } |
4422 iCount++; | 4499 iCount++; |
4423 if (iCount > index) { | 4500 if (iCount > index) { |
4424 return pNode; | 4501 return pNode; |
4425 } | 4502 } |
4426 } | 4503 } |
4427 } | 4504 } |
4428 return nullptr; | 4505 return nullptr; |
4429 } | 4506 } |
| 4507 |
4430 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { | 4508 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { |
4431 ASSERT(!pNode->m_pNext); | 4509 ASSERT(!pNode->m_pNext); |
4432 pNode->m_pParent = this; | 4510 pNode->m_pParent = this; |
4433 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); | 4511 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); |
4434 ASSERT(ret); | 4512 ASSERT(ret); |
4435 (void)ret; // Avoid unused variable warning. | 4513 (void)ret; // Avoid unused variable warning. |
4436 | 4514 |
4437 if (!m_pChild || index == 0) { | 4515 if (!m_pChild || index == 0) { |
4438 if (index > 0) { | 4516 if (index > 0) { |
4439 return -1; | 4517 return -1; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4513 if (pNotify) | 4591 if (pNotify) |
4514 pNotify->OnChildAdded(this); | 4592 pNotify->OnChildAdded(this); |
4515 | 4593 |
4516 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4594 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
4517 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); | 4595 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); |
4518 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); | 4596 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); |
4519 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); | 4597 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); |
4520 } | 4598 } |
4521 return TRUE; | 4599 return TRUE; |
4522 } | 4600 } |
| 4601 |
4523 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { | 4602 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { |
4524 if (!m_pParent) { | 4603 if (!m_pParent) { |
4525 return nullptr; | 4604 return nullptr; |
4526 } | 4605 } |
4527 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; | 4606 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; |
4528 pSibling = pSibling->m_pNext) { | 4607 pSibling = pSibling->m_pNext) { |
4529 if (pSibling->m_pNext == this) { | 4608 if (pSibling->m_pNext == this) { |
4530 return pSibling; | 4609 return pSibling; |
4531 } | 4610 } |
4532 } | 4611 } |
4533 return nullptr; | 4612 return nullptr; |
4534 } | 4613 } |
| 4614 |
4535 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { | 4615 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { |
4536 if (!pNode || pNode->m_pParent != this) { | 4616 if (!pNode || pNode->m_pParent != this) { |
4537 ASSERT(FALSE); | 4617 ASSERT(FALSE); |
4538 return FALSE; | 4618 return FALSE; |
4539 } | 4619 } |
4540 if (m_pChild == pNode) { | 4620 if (m_pChild == pNode) { |
4541 m_pChild = pNode->m_pNext; | 4621 m_pChild = pNode->m_pNext; |
4542 if (m_pLastChild == pNode) { | 4622 if (m_pLastChild == pNode) { |
4543 m_pLastChild = pNode->m_pNext; | 4623 m_pLastChild = pNode->m_pNext; |
4544 } | 4624 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4577 } | 4657 } |
4578 pNode->m_pXMLNode = pNewXMLElement; | 4658 pNode->m_pXMLNode = pNewXMLElement; |
4579 pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); | 4659 pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); |
4580 } else { | 4660 } else { |
4581 m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode); | 4661 m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode); |
4582 } | 4662 } |
4583 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false); | 4663 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false); |
4584 } | 4664 } |
4585 return TRUE; | 4665 return TRUE; |
4586 } | 4666 } |
| 4667 |
4587 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { | 4668 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { |
4588 return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); | 4669 return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); |
4589 } | 4670 } |
| 4671 |
4590 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { | 4672 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { |
4591 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; | 4673 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; |
4592 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4674 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4593 if (pNode->GetNameHash() == dwNameHash) { | 4675 if (pNode->GetNameHash() == dwNameHash) { |
4594 return pNode; | 4676 return pNode; |
4595 } | 4677 } |
4596 } | 4678 } |
4597 return nullptr; | 4679 return nullptr; |
4598 } | 4680 } |
| 4681 |
4599 CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_Element eType) const { | 4682 CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_Element eType) const { |
4600 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; | 4683 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; |
4601 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4684 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4602 if (pNode->GetElementType() == eType) { | 4685 if (pNode->GetElementType() == eType) { |
4603 return pNode; | 4686 return pNode; |
4604 } | 4687 } |
4605 } | 4688 } |
4606 return nullptr; | 4689 return nullptr; |
4607 } | 4690 } |
| 4691 |
4608 CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const { | 4692 CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const { |
4609 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; | 4693 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; |
4610 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4694 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4611 if (pNode->GetNameHash() == dwNameHash) { | 4695 if (pNode->GetNameHash() == dwNameHash) { |
4612 return pNode; | 4696 return pNode; |
4613 } | 4697 } |
4614 } | 4698 } |
4615 return nullptr; | 4699 return nullptr; |
4616 } | 4700 } |
| 4701 |
4617 CXFA_Node* CXFA_Node::GetNextSameNameSibling( | 4702 CXFA_Node* CXFA_Node::GetNextSameNameSibling( |
4618 const CFX_WideStringC& wsNodeName) const { | 4703 const CFX_WideStringC& wsNodeName) const { |
4619 return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); | 4704 return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); |
4620 } | 4705 } |
| 4706 |
4621 CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_Element eType) const { | 4707 CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_Element eType) const { |
4622 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; | 4708 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; |
4623 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4709 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
4624 if (pNode->GetElementType() == eType) { | 4710 if (pNode->GetElementType() == eType) { |
4625 return pNode; | 4711 return pNode; |
4626 } | 4712 } |
4627 } | 4713 } |
4628 return nullptr; | 4714 return nullptr; |
4629 } | 4715 } |
| 4716 |
4630 int32_t CXFA_Node::GetNodeSameNameIndex() const { | 4717 int32_t CXFA_Node::GetNodeSameNameIndex() const { |
4631 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4718 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
4632 if (!pScriptContext) { | 4719 if (!pScriptContext) { |
4633 return -1; | 4720 return -1; |
4634 } | 4721 } |
4635 return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); | 4722 return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); |
4636 } | 4723 } |
| 4724 |
4637 int32_t CXFA_Node::GetNodeSameClassIndex() const { | 4725 int32_t CXFA_Node::GetNodeSameClassIndex() const { |
4638 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4726 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
4639 if (!pScriptContext) { | 4727 if (!pScriptContext) { |
4640 return -1; | 4728 return -1; |
4641 } | 4729 } |
4642 return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); | 4730 return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); |
4643 } | 4731 } |
| 4732 |
4644 void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { | 4733 void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { |
4645 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4734 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
4646 if (!pScriptContext) { | 4735 if (!pScriptContext) { |
4647 return; | 4736 return; |
4648 } | 4737 } |
4649 pScriptContext->GetSomExpression(this, wsSOMExpression); | 4738 pScriptContext->GetSomExpression(this, wsSOMExpression); |
4650 } | 4739 } |
| 4740 |
4651 CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { | 4741 CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { |
4652 CXFA_Node* pInstanceMgr = nullptr; | 4742 CXFA_Node* pInstanceMgr = nullptr; |
4653 if (m_ePacket == XFA_XDPPACKET_Form) { | 4743 if (m_ePacket == XFA_XDPPACKET_Form) { |
4654 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 4744 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
4655 if (!pParentNode || pParentNode->GetElementType() == XFA_Element::Area) { | 4745 if (!pParentNode || pParentNode->GetElementType() == XFA_Element::Area) { |
4656 return pInstanceMgr; | 4746 return pInstanceMgr; |
4657 } | 4747 } |
4658 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 4748 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
4659 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 4749 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
4660 XFA_Element eType = pNode->GetElementType(); | 4750 XFA_Element eType = pNode->GetElementType(); |
4661 if ((eType == XFA_Element::Subform || eType == XFA_Element::SubformSet) && | 4751 if ((eType == XFA_Element::Subform || eType == XFA_Element::SubformSet) && |
4662 pNode->m_dwNameHash != m_dwNameHash) { | 4752 pNode->m_dwNameHash != m_dwNameHash) { |
4663 break; | 4753 break; |
4664 } | 4754 } |
4665 if (eType == XFA_Element::InstanceManager) { | 4755 if (eType == XFA_Element::InstanceManager) { |
4666 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); | 4756 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); |
4667 CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name); | 4757 CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
4668 if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' && | 4758 if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' && |
4669 wsInstName.Mid(1) == wsName) { | 4759 wsInstName.Mid(1) == wsName) { |
4670 pInstanceMgr = pNode; | 4760 pInstanceMgr = pNode; |
4671 } | 4761 } |
4672 break; | 4762 break; |
4673 } | 4763 } |
4674 } | 4764 } |
4675 } | 4765 } |
4676 return pInstanceMgr; | 4766 return pInstanceMgr; |
4677 } | 4767 } |
| 4768 |
4678 CXFA_Node* CXFA_Node::GetOccurNode() { | 4769 CXFA_Node* CXFA_Node::GetOccurNode() { |
4679 return GetFirstChildByClass(XFA_Element::Occur); | 4770 return GetFirstChildByClass(XFA_Element::Occur); |
4680 } | 4771 } |
| 4772 |
4681 bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const { | 4773 bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const { |
4682 if (m_uNodeFlags & dwFlag) | 4774 if (m_uNodeFlags & dwFlag) |
4683 return true; | 4775 return true; |
4684 if (dwFlag == XFA_NodeFlag_HasRemovedChildren) | 4776 if (dwFlag == XFA_NodeFlag_HasRemovedChildren) |
4685 return m_pParent && m_pParent->HasFlag(dwFlag); | 4777 return m_pParent && m_pParent->HasFlag(dwFlag); |
4686 return false; | 4778 return false; |
4687 } | 4779 } |
4688 | 4780 |
4689 void CXFA_Node::SetFlag(uint32_t dwFlag, bool bNotify) { | 4781 void CXFA_Node::SetFlag(uint32_t dwFlag, bool bNotify) { |
4690 if (dwFlag == XFA_NodeFlag_Initialized && bNotify && !IsInitialized()) { | 4782 if (dwFlag == XFA_NodeFlag_Initialized && bNotify && !IsInitialized()) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4783 if ((pUINode->m_elementType == XFA_Element::ChoiceList) && | 4875 if ((pUINode->m_elementType == XFA_Element::ChoiceList) && |
4784 (!pWidgetData->IsListBox())) { | 4876 (!pWidgetData->IsListBox())) { |
4785 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, | 4877 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, |
4786 FALSE, FALSE); | 4878 FALSE, FALSE); |
4787 } | 4879 } |
4788 } | 4880 } |
4789 } | 4881 } |
4790 } | 4882 } |
4791 return iRet; | 4883 return iRet; |
4792 } | 4884 } |
| 4885 |
4793 void CXFA_Node::UpdateNameHash() { | 4886 void CXFA_Node::UpdateNameHash() { |
4794 const XFA_NOTSUREATTRIBUTE* pNotsure = | 4887 const XFA_NOTSUREATTRIBUTE* pNotsure = |
4795 XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name); | 4888 XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name); |
4796 CFX_WideStringC wsName; | 4889 CFX_WideStringC wsName; |
4797 if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { | 4890 if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { |
4798 wsName = GetCData(XFA_ATTRIBUTE_Name); | 4891 wsName = GetCData(XFA_ATTRIBUTE_Name); |
4799 m_dwNameHash = FX_HashCode_GetW(wsName, false); | 4892 m_dwNameHash = FX_HashCode_GetW(wsName, false); |
4800 } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) { | 4893 } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) { |
4801 wsName = XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName; | 4894 wsName = XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName; |
4802 m_dwNameHash = FX_HashCode_GetW(wsName, false); | 4895 m_dwNameHash = FX_HashCode_GetW(wsName, false); |
4803 } | 4896 } |
4804 } | 4897 } |
| 4898 |
4805 CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { | 4899 CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { |
4806 if (!m_pXMLNode) { | 4900 if (!m_pXMLNode) { |
4807 CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name)); | 4901 CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name)); |
4808 m_pXMLNode = new CFDE_XMLElement(wsTag); | 4902 m_pXMLNode = new CFDE_XMLElement(wsTag); |
4809 SetFlag(XFA_NodeFlag_OwnXMLNode, false); | 4903 SetFlag(XFA_NodeFlag_OwnXMLNode, false); |
4810 } | 4904 } |
4811 return m_pXMLNode; | 4905 return m_pXMLNode; |
4812 } | 4906 } |
| 4907 |
4813 FX_BOOL CXFA_Node::IsNeedSavingXMLNode() { | 4908 FX_BOOL CXFA_Node::IsNeedSavingXMLNode() { |
4814 return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets || | 4909 return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets || |
4815 GetElementType() == XFA_Element::Xfa); | 4910 GetElementType() == XFA_Element::Xfa); |
4816 } | 4911 } |
4817 | 4912 |
4818 XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() { | 4913 XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() { |
4819 if (!m_pMapModuleData) | 4914 if (!m_pMapModuleData) |
4820 m_pMapModuleData = new XFA_MAPMODULEDATA; | 4915 m_pMapModuleData = new XFA_MAPMODULEDATA; |
4821 return m_pMapModuleData; | 4916 return m_pMapModuleData; |
4822 } | 4917 } |
(...skipping 13 matching lines...) Expand all Loading... |
4836 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 4931 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
4837 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { | 4932 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { |
4838 return TRUE; | 4933 return TRUE; |
4839 } | 4934 } |
4840 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets | 4935 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets |
4841 ? pNode->GetTemplateNode() | 4936 ? pNode->GetTemplateNode() |
4842 : nullptr; | 4937 : nullptr; |
4843 } | 4938 } |
4844 return FALSE; | 4939 return FALSE; |
4845 } | 4940 } |
| 4941 |
4846 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { | 4942 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { |
4847 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(), | 4943 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(), |
4848 wsValue.GetLength() * sizeof(FX_WCHAR)); | 4944 wsValue.GetLength() * sizeof(FX_WCHAR)); |
4849 } | 4945 } |
| 4946 |
4850 FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { | 4947 FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { |
4851 void* pValue; | 4948 void* pValue; |
4852 int32_t iBytes; | 4949 int32_t iBytes; |
4853 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { | 4950 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { |
4854 return FALSE; | 4951 return FALSE; |
4855 } | 4952 } |
4856 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); | 4953 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); |
4857 return TRUE; | 4954 return TRUE; |
4858 } | 4955 } |
| 4956 |
4859 void CXFA_Node::SetMapModuleBuffer( | 4957 void CXFA_Node::SetMapModuleBuffer( |
4860 void* pKey, | 4958 void* pKey, |
4861 void* pValue, | 4959 void* pValue, |
4862 int32_t iBytes, | 4960 int32_t iBytes, |
4863 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4961 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
4864 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); | 4962 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); |
4865 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; | 4963 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; |
4866 if (!pBuffer) { | 4964 if (!pBuffer) { |
4867 pBuffer = | 4965 pBuffer = |
4868 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); | 4966 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); |
4869 } else if (pBuffer->iBytes != iBytes) { | 4967 } else if (pBuffer->iBytes != iBytes) { |
4870 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 4968 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
4871 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 4969 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
4872 } | 4970 } |
4873 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, | 4971 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, |
4874 sizeof(XFA_MAPDATABLOCK) + iBytes); | 4972 sizeof(XFA_MAPDATABLOCK) + iBytes); |
4875 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 4973 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
4876 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 4974 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
4877 } | 4975 } |
4878 if (!pBuffer) | 4976 if (!pBuffer) |
4879 return; | 4977 return; |
4880 | 4978 |
4881 pBuffer->pCallbackInfo = pCallbackInfo; | 4979 pBuffer->pCallbackInfo = pCallbackInfo; |
4882 pBuffer->iBytes = iBytes; | 4980 pBuffer->iBytes = iBytes; |
4883 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); | 4981 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); |
4884 } | 4982 } |
| 4983 |
4885 FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, | 4984 FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, |
4886 void*& pValue, | 4985 void*& pValue, |
4887 int32_t& iBytes, | 4986 int32_t& iBytes, |
4888 FX_BOOL bProtoAlso) const { | 4987 FX_BOOL bProtoAlso) const { |
4889 XFA_MAPDATABLOCK* pBuffer = nullptr; | 4988 XFA_MAPDATABLOCK* pBuffer = nullptr; |
4890 const CXFA_Node* pNode = this; | 4989 const CXFA_Node* pNode = this; |
4891 while (pNode) { | 4990 while (pNode) { |
4892 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 4991 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
4893 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { | 4992 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { |
4894 break; | 4993 break; |
4895 } | 4994 } |
4896 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) | 4995 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) |
4897 ? pNode->GetTemplateNode() | 4996 ? pNode->GetTemplateNode() |
4898 : nullptr; | 4997 : nullptr; |
4899 } | 4998 } |
4900 if (!pBuffer) { | 4999 if (!pBuffer) { |
4901 return FALSE; | 5000 return FALSE; |
4902 } | 5001 } |
4903 pValue = pBuffer->GetData(); | 5002 pValue = pBuffer->GetData(); |
4904 iBytes = pBuffer->iBytes; | 5003 iBytes = pBuffer->iBytes; |
4905 return TRUE; | 5004 return TRUE; |
4906 } | 5005 } |
| 5006 |
4907 FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { | 5007 FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { |
4908 CXFA_Node* pNode = this; | 5008 CXFA_Node* pNode = this; |
4909 while (pNode) { | 5009 while (pNode) { |
4910 void* pVal; | 5010 void* pVal; |
4911 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 5011 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
4912 if (pModule && | 5012 if (pModule && |
4913 (pModule->m_ValueMap.Lookup(pKey, pVal) || | 5013 (pModule->m_ValueMap.Lookup(pKey, pVal) || |
4914 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { | 5014 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { |
4915 return TRUE; | 5015 return TRUE; |
4916 } | 5016 } |
4917 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) | 5017 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) |
4918 ? pNode->GetTemplateNode() | 5018 ? pNode->GetTemplateNode() |
4919 : nullptr; | 5019 : nullptr; |
4920 } | 5020 } |
4921 return FALSE; | 5021 return FALSE; |
4922 } | 5022 } |
| 5023 |
4923 void CXFA_Node::RemoveMapModuleKey(void* pKey) { | 5024 void CXFA_Node::RemoveMapModuleKey(void* pKey) { |
4924 XFA_MAPMODULEDATA* pModule = GetMapModuleData(); | 5025 XFA_MAPMODULEDATA* pModule = GetMapModuleData(); |
4925 if (!pModule) | 5026 if (!pModule) |
4926 return; | 5027 return; |
4927 | 5028 |
4928 if (pKey) { | 5029 if (pKey) { |
4929 XFA_MAPDATABLOCK* pBuffer = nullptr; | 5030 XFA_MAPDATABLOCK* pBuffer = nullptr; |
4930 pModule->m_BufferMap.Lookup(pKey, pBuffer); | 5031 pModule->m_BufferMap.Lookup(pKey, pBuffer); |
4931 if (pBuffer) { | 5032 if (pBuffer) { |
4932 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 5033 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
(...skipping 13 matching lines...) Expand all Loading... |
4946 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 5047 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
4947 } | 5048 } |
4948 FX_Free(pBuffer); | 5049 FX_Free(pBuffer); |
4949 } | 5050 } |
4950 } | 5051 } |
4951 pModule->m_BufferMap.RemoveAll(); | 5052 pModule->m_BufferMap.RemoveAll(); |
4952 pModule->m_ValueMap.RemoveAll(); | 5053 pModule->m_ValueMap.RemoveAll(); |
4953 delete pModule; | 5054 delete pModule; |
4954 } | 5055 } |
4955 } | 5056 } |
| 5057 |
4956 void CXFA_Node::MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr) { | 5058 void CXFA_Node::MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr) { |
4957 XFA_MAPMODULEDATA* pDstModuleData = | 5059 XFA_MAPMODULEDATA* pDstModuleData = |
4958 static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData(); | 5060 static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData(); |
4959 XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); | 5061 XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); |
4960 if (!pSrcModuleData) { | 5062 if (!pSrcModuleData) { |
4961 return; | 5063 return; |
4962 } | 5064 } |
4963 FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition(); | 5065 FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition(); |
4964 while (psValue) { | 5066 while (psValue) { |
4965 void* pKey; | 5067 void* pKey; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5002 continue; | 5104 continue; |
5003 } | 5105 } |
5004 pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; | 5106 pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; |
5005 pBuffer->iBytes = pSrcBuffer->iBytes; | 5107 pBuffer->iBytes = pSrcBuffer->iBytes; |
5006 FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); | 5108 FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); |
5007 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { | 5109 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { |
5008 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); | 5110 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); |
5009 } | 5111 } |
5010 } | 5112 } |
5011 } | 5113 } |
| 5114 |
5012 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { | 5115 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { |
5013 if (!pDstModule) { | 5116 if (!pDstModule) { |
5014 return; | 5117 return; |
5015 } | 5118 } |
5016 FX_BOOL bNeedMove = TRUE; | 5119 FX_BOOL bNeedMove = TRUE; |
5017 if (!pKey) { | 5120 if (!pKey) { |
5018 bNeedMove = FALSE; | 5121 bNeedMove = FALSE; |
5019 } | 5122 } |
5020 if (pDstModule->GetElementType() != GetElementType()) { | 5123 if (pDstModule->GetElementType() != GetElementType()) { |
5021 bNeedMove = FALSE; | 5124 bNeedMove = FALSE; |
(...skipping 19 matching lines...) Expand all Loading... |
5041 if (pDstModule->IsNodeV()) { | 5144 if (pDstModule->IsNodeV()) { |
5042 CFX_WideString wsValue = pDstModule->GetScriptContent(FALSE); | 5145 CFX_WideString wsValue = pDstModule->GetScriptContent(FALSE); |
5043 CFX_WideString wsFormatValue(wsValue); | 5146 CFX_WideString wsFormatValue(wsValue); |
5044 CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData(); | 5147 CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData(); |
5045 if (pWidgetData) { | 5148 if (pWidgetData) { |
5046 pWidgetData->GetFormatDataValue(wsValue, wsFormatValue); | 5149 pWidgetData->GetFormatDataValue(wsValue, wsFormatValue); |
5047 } | 5150 } |
5048 pDstModule->SetScriptContent(wsValue, wsFormatValue, true, TRUE); | 5151 pDstModule->SetScriptContent(wsValue, wsFormatValue, true, TRUE); |
5049 } | 5152 } |
5050 } | 5153 } |
| 5154 |
5051 void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule, | 5155 void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule, |
5052 CXFA_Node* pDstModule, | 5156 CXFA_Node* pDstModule, |
5053 void* pKey, | 5157 void* pKey, |
5054 FX_BOOL bRecursive) { | 5158 FX_BOOL bRecursive) { |
5055 if (!pSrcModule || !pDstModule || !pKey) { | 5159 if (!pSrcModule || !pDstModule || !pKey) { |
5056 return; | 5160 return; |
5057 } | 5161 } |
5058 if (bRecursive) { | 5162 if (bRecursive) { |
5059 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5163 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5060 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5164 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5061 for (; pSrcChild && pDstChild; | 5165 for (; pSrcChild && pDstChild; |
5062 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), | 5166 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), |
5063 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 5167 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
5064 MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); | 5168 MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); |
5065 } | 5169 } |
5066 } | 5170 } |
5067 pSrcModule->MoveBufferMapData(pDstModule, pKey); | 5171 pSrcModule->MoveBufferMapData(pDstModule, pKey); |
5068 } | 5172 } |
5069 | |
5070 CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) | |
5071 : CXFA_Object(pThisNode->GetDocument(), | |
5072 XFA_ObjectType::VariablesThis, | |
5073 XFA_Element::Unknown, | |
5074 CFX_WideStringC()), | |
5075 m_pThisNode(nullptr), | |
5076 m_pScriptNode(nullptr) { | |
5077 m_pThisNode = pThisNode; | |
5078 m_pScriptNode = pScriptNode; | |
5079 } | |
5080 | |
5081 CXFA_ThisProxy::~CXFA_ThisProxy() {} | |
5082 | |
5083 CXFA_Node* CXFA_ThisProxy::GetThisNode() const { | |
5084 return m_pThisNode; | |
5085 } | |
5086 | |
5087 CXFA_Node* CXFA_ThisProxy::GetScriptNode() const { | |
5088 return m_pScriptNode; | |
5089 } | |
5090 | |
5091 CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) | |
5092 : CXFA_Object(pDocument, | |
5093 XFA_ObjectType::NodeList, | |
5094 XFA_Element::NodeList, | |
5095 CFX_WideStringC(L"nodeList")) { | |
5096 m_pDocument->GetScriptContext()->AddToCacheList( | |
5097 std::unique_ptr<CXFA_NodeList>(this)); | |
5098 } | |
5099 | |
5100 CXFA_NodeList::~CXFA_NodeList() {} | |
5101 | |
5102 CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { | |
5103 uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); | |
5104 int32_t iCount = GetLength(); | |
5105 for (int32_t i = 0; i < iCount; i++) { | |
5106 CXFA_Node* ret = Item(i); | |
5107 if (dwHashCode == ret->GetNameHash()) | |
5108 return ret; | |
5109 } | |
5110 return nullptr; | |
5111 } | |
5112 void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { | |
5113 int32_t argc = pArguments->GetLength(); | |
5114 if (argc == 1) { | |
5115 CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | |
5116 if (pNode) { | |
5117 Append(pNode); | |
5118 } else { | |
5119 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | |
5120 } | |
5121 } else { | |
5122 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"append"); | |
5123 } | |
5124 } | |
5125 void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) { | |
5126 int32_t argc = pArguments->GetLength(); | |
5127 if (argc == 2) { | |
5128 CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | |
5129 CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1)); | |
5130 if (pNewNode) { | |
5131 Insert(pNewNode, pBeforeNode); | |
5132 } else { | |
5133 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | |
5134 } | |
5135 } else { | |
5136 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insert"); | |
5137 } | |
5138 } | |
5139 void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) { | |
5140 int32_t argc = pArguments->GetLength(); | |
5141 if (argc == 1) { | |
5142 CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | |
5143 if (pNode) { | |
5144 Remove(pNode); | |
5145 } else { | |
5146 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | |
5147 } | |
5148 } else { | |
5149 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove"); | |
5150 } | |
5151 } | |
5152 void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { | |
5153 int32_t argc = pArguments->GetLength(); | |
5154 if (argc == 1) { | |
5155 int32_t iIndex = pArguments->GetInt32(0); | |
5156 if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) { | |
5157 pArguments->GetReturnValue()->Assign( | |
5158 m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex))); | |
5159 } else { | |
5160 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | |
5161 } | |
5162 } else { | |
5163 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item"); | |
5164 } | |
5165 } | |
5166 void CXFA_NodeList::Script_TreelistClass_NamedItem( | |
5167 CFXJSE_Arguments* pArguments) { | |
5168 int32_t argc = pArguments->GetLength(); | |
5169 if (argc == 1) { | |
5170 CFX_ByteString szName = pArguments->GetUTF8String(0); | |
5171 CXFA_Node* pNode = | |
5172 NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC()); | |
5173 if (!pNode) { | |
5174 return; | |
5175 } | |
5176 pArguments->GetReturnValue()->Assign( | |
5177 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | |
5178 } else { | |
5179 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem"); | |
5180 } | |
5181 } | |
5182 void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue, | |
5183 FX_BOOL bSetting, | |
5184 XFA_ATTRIBUTE eAttribute) { | |
5185 if (!bSetting) { | |
5186 pValue->SetInteger(GetLength()); | |
5187 } else { | |
5188 ThrowException(XFA_IDS_INVAlID_PROP_SET); | |
5189 } | |
5190 } | |
5191 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) | |
5192 : CXFA_NodeList(pDocument) {} | |
5193 | |
5194 CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {} | |
5195 | |
5196 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { | |
5197 if (srcArray.GetSize() > 0) { | |
5198 m_array.Copy(srcArray); | |
5199 } | |
5200 } | |
5201 int32_t CXFA_ArrayNodeList::GetLength() { | |
5202 return m_array.GetSize(); | |
5203 } | |
5204 FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { | |
5205 m_array.Add(pNode); | |
5206 return TRUE; | |
5207 } | |
5208 FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, | |
5209 CXFA_Node* pBeforeNode) { | |
5210 if (!pBeforeNode) { | |
5211 m_array.Add(pNewNode); | |
5212 } else { | |
5213 int32_t iSize = m_array.GetSize(); | |
5214 for (int32_t i = 0; i < iSize; ++i) { | |
5215 if (m_array[i] == pBeforeNode) { | |
5216 m_array.InsertAt(i, pNewNode); | |
5217 break; | |
5218 } | |
5219 } | |
5220 } | |
5221 return TRUE; | |
5222 } | |
5223 FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { | |
5224 int32_t iSize = m_array.GetSize(); | |
5225 for (int32_t i = 0; i < iSize; ++i) { | |
5226 if (m_array[i] == pNode) { | |
5227 m_array.RemoveAt(i); | |
5228 break; | |
5229 } | |
5230 } | |
5231 return TRUE; | |
5232 } | |
5233 CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { | |
5234 int32_t iSize = m_array.GetSize(); | |
5235 if (iIndex >= 0 && iIndex < iSize) { | |
5236 return m_array[iIndex]; | |
5237 } | |
5238 return nullptr; | |
5239 } | |
5240 CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, | |
5241 CXFA_Node* pAttachNode) | |
5242 : CXFA_NodeList(pDocument) { | |
5243 m_pAttachNode = pAttachNode; | |
5244 } | |
5245 int32_t CXFA_AttachNodeList::GetLength() { | |
5246 return m_pAttachNode->CountChildren( | |
5247 XFA_Element::Unknown, | |
5248 m_pAttachNode->GetElementType() == XFA_Element::Subform); | |
5249 } | |
5250 FX_BOOL CXFA_AttachNodeList::Append(CXFA_Node* pNode) { | |
5251 CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); | |
5252 if (pParent) { | |
5253 pParent->RemoveChild(pNode); | |
5254 } | |
5255 return m_pAttachNode->InsertChild(pNode); | |
5256 } | |
5257 FX_BOOL CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, | |
5258 CXFA_Node* pBeforeNode) { | |
5259 CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); | |
5260 if (pParent) { | |
5261 pParent->RemoveChild(pNewNode); | |
5262 } | |
5263 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | |
5264 } | |
5265 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | |
5266 return m_pAttachNode->RemoveChild(pNode); | |
5267 } | |
5268 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | |
5269 return m_pAttachNode->GetChild( | |
5270 iIndex, XFA_Element::Unknown, | |
5271 m_pAttachNode->GetElementType() == XFA_Element::Subform); | |
5272 } | |
OLD | NEW |