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