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

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

Issue 2123133004: Remove IXFA_Parser, cleanup XFA parser code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_localevalue.cpp ('k') | xfa/fxfa/parser/xfa_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/xfa_object.h" 7 #include "xfa/fxfa/parser/xfa_object.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "core/fxcrt/include/fx_ext.h" 11 #include "core/fxcrt/include/fx_ext.h"
12 #include "fxjse/include/cfxjse_arguments.h" 12 #include "fxjse/include/cfxjse_arguments.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/parser/cxfa_occur.h" 18 #include "xfa/fxfa/parser/cxfa_occur.h"
19 #include "xfa/fxfa/parser/xfa_basic_imp.h" 19 #include "xfa/fxfa/parser/xfa_basic_imp.h"
20 #include "xfa/fxfa/parser/xfa_doclayout.h" 20 #include "xfa/fxfa/parser/xfa_doclayout.h"
21 #include "xfa/fxfa/parser/xfa_document.h" 21 #include "xfa/fxfa/parser/xfa_document.h"
22 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" 22 #include "xfa/fxfa/parser/xfa_document_layout_imp.h"
23 #include "xfa/fxfa/parser/xfa_localemgr.h" 23 #include "xfa/fxfa/parser/xfa_localemgr.h"
24 #include "xfa/fxfa/parser/xfa_parser.h"
25 #include "xfa/fxfa/parser/xfa_parser_imp.h" 24 #include "xfa/fxfa/parser/xfa_parser_imp.h"
26 #include "xfa/fxfa/parser/xfa_script.h" 25 #include "xfa/fxfa/parser/xfa_script.h"
27 #include "xfa/fxfa/parser/xfa_script_imp.h" 26 #include "xfa/fxfa/parser/xfa_script_imp.h"
28 #include "xfa/fxfa/parser/xfa_utils.h" 27 #include "xfa/fxfa/parser/xfa_utils.h"
29 28
30 namespace { 29 namespace {
31 30
32 void XFA_DeleteWideString(void* pData) { 31 void XFA_DeleteWideString(void* pData) {
33 delete static_cast<CFX_WideString*>(pData); 32 delete static_cast<CFX_WideString*>(pData);
34 } 33 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 CXFA_Node* pNext = pNode->m_pNext; 128 CXFA_Node* pNext = pNode->m_pNext;
130 pNode->m_pParent = nullptr; 129 pNode->m_pParent = nullptr;
131 delete pNode; 130 delete pNode;
132 pNode = pNext; 131 pNode = pNext;
133 } 132 }
134 if (m_pXMLNode && IsOwnXMLNode()) 133 if (m_pXMLNode && IsOwnXMLNode())
135 m_pXMLNode->Release(); 134 m_pXMLNode->Release();
136 } 135 }
137 136
138 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { 137 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) {
139 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); 138 CXFA_Node* pClone = m_pDocument->CreateNode(m_ePacket, m_elementType);
140 CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_elementType);
141 if (!pClone) 139 if (!pClone)
142 return nullptr; 140 return nullptr;
143 141
144 MergeAllData(pClone); 142 MergeAllData(pClone);
145 pClone->UpdateNameHash(); 143 pClone->UpdateNameHash();
146 if (IsNeedSavingXMLNode()) { 144 if (IsNeedSavingXMLNode()) {
147 CFDE_XMLNode* pCloneXML = nullptr; 145 CFDE_XMLNode* pCloneXML = nullptr;
148 if (IsAttributeInXML()) { 146 if (IsAttributeInXML()) {
149 CFX_WideString wsName; 147 CFX_WideString wsName;
150 GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 148 GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 pChild = pChild->m_pNext; 286 pChild = pChild->m_pNext;
289 } 287 }
290 if (bFilterOneOfProperties && nodes.GetSize() < 1) { 288 if (bFilterOneOfProperties && nodes.GetSize() < 1) {
291 int32_t iProperties = 0; 289 int32_t iProperties = 0;
292 const XFA_PROPERTY* pProperty = 290 const XFA_PROPERTY* pProperty =
293 XFA_GetElementProperties(GetElementType(), iProperties); 291 XFA_GetElementProperties(GetElementType(), iProperties);
294 if (!pProperty || iProperties < 1) 292 if (!pProperty || iProperties < 1)
295 return 0; 293 return 0;
296 for (int32_t i = 0; i < iProperties; i++) { 294 for (int32_t i = 0; i < iProperties; i++) {
297 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { 295 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) {
298 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory();
299 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); 296 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID());
300 CXFA_Node* pNewNode = 297 CXFA_Node* pNewNode =
301 pFactory->CreateNode(pPacket, pProperty[i].eName); 298 m_pDocument->CreateNode(pPacket, pProperty[i].eName);
302 if (!pNewNode) 299 if (!pNewNode)
303 break; 300 break;
304 InsertChild(pNewNode, nullptr); 301 InsertChild(pNewNode, nullptr);
305 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); 302 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
306 nodes.Add(pNewNode); 303 nodes.Add(pNewNode);
307 break; 304 break;
308 } 305 }
309 } 306 }
310 } 307 }
311 } 308 }
312 return nodes.GetSize(); 309 return nodes.GetSize();
313 } 310 }
314 311
315 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType, 312 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType,
316 uint32_t dwFlags) { 313 uint32_t dwFlags) {
317 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); 314 CXFA_Node* pNode = m_pDocument->CreateNode(m_ePacket, eType);
318 CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eType);
319 pNode->SetFlag(dwFlags, true); 315 pNode->SetFlag(dwFlags, true);
320 return pNode; 316 return pNode;
321 } 317 }
322 318
323 CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { 319 CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) {
324 ASSERT(m_ePacket == XFA_XDPPACKET_Template); 320 ASSERT(m_ePacket == XFA_XDPPACKET_Template);
325 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); 321 CXFA_Node* pClone =
326 CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_elementType); 322 m_pDocument->CreateNode(XFA_XDPPACKET_Form, m_elementType);
327 if (!pClone) 323 if (!pClone)
328 return nullptr; 324 return nullptr;
329 325
330 pClone->SetTemplateNode(this); 326 pClone->SetTemplateNode(this);
331 pClone->UpdateNameHash(); 327 pClone->UpdateNameHash();
332 pClone->SetXMLMappingNode(GetXMLMappingNode()); 328 pClone->SetXMLMappingNode(GetXMLMappingNode());
333 if (bRecursive) { 329 if (bRecursive) {
334 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; 330 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild;
335 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 331 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
336 pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive)); 332 pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive));
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 bool bIgnoreRoot = true; 927 bool bIgnoreRoot = true;
932 bool bOverwrite = 0; 928 bool bOverwrite = 0;
933 wsExpression = 929 wsExpression =
934 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); 930 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
935 if (wsExpression.IsEmpty()) 931 if (wsExpression.IsEmpty())
936 return; 932 return;
937 if (iLength >= 2) 933 if (iLength >= 2)
938 bIgnoreRoot = !!pArguments->GetInt32(1); 934 bIgnoreRoot = !!pArguments->GetInt32(1);
939 if (iLength >= 3) 935 if (iLength >= 3)
940 bOverwrite = !!pArguments->GetInt32(2); 936 bOverwrite = !!pArguments->GetInt32(2);
941 std::unique_ptr<IXFA_Parser, ReleaseDeleter<IXFA_Parser>> pParser( 937 std::unique_ptr<CXFA_SimpleParser> pParser(
942 IXFA_Parser::Create(m_pDocument)); 938 new CXFA_SimpleParser(m_pDocument, false));
943 if (!pParser) 939 if (!pParser)
944 return; 940 return;
945 CFDE_XMLNode* pXMLNode = nullptr; 941 CFDE_XMLNode* pXMLNode = nullptr;
946 int32_t iParserStatus = 942 int32_t iParserStatus =
947 pParser->ParseXMLData(wsExpression, pXMLNode, nullptr); 943 pParser->ParseXMLData(wsExpression, pXMLNode, nullptr);
948 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) 944 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode)
949 return; 945 return;
950 if (bIgnoreRoot && 946 if (bIgnoreRoot &&
951 (pXMLNode->GetType() != FDE_XMLNODE_Element || 947 (pXMLNode->GetType() != FDE_XMLNODE_Element ||
952 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { 948 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1254 }
1259 } 1255 }
1260 1256
1261 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( 1257 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage(
1262 XFA_ATTRIBUTE eAttribute, 1258 XFA_ATTRIBUTE eAttribute,
1263 FX_BOOL bScriptModify) { 1259 FX_BOOL bScriptModify) {
1264 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 1260 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
1265 if (!pLayoutPro) 1261 if (!pLayoutPro)
1266 return; 1262 return;
1267 1263
1268 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 1264 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1269 if (!pNotify) 1265 if (!pNotify)
1270 return; 1266 return;
1271 1267
1272 uint32_t dwPacket = GetPacketID(); 1268 uint32_t dwPacket = GetPacketID();
1273 if (!(dwPacket & XFA_XDPPACKET_Form)) { 1269 if (!(dwPacket & XFA_XDPPACKET_Form)) {
1274 pNotify->OnValueChanged(this, eAttribute, this, this); 1270 pNotify->OnValueChanged(this, eAttribute, this, this);
1275 return; 1271 return;
1276 } 1272 }
1277 1273
1278 bool bNeedFindContainer = false; 1274 bool bNeedFindContainer = false;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 case XFA_SOM_FormatMessage: 1530 case XFA_SOM_FormatMessage:
1535 validate.SetFormatMessageText(pValue->ToWideString()); 1531 validate.SetFormatMessageText(pValue->ToWideString());
1536 break; 1532 break;
1537 case XFA_SOM_MandatoryMessage: 1533 case XFA_SOM_MandatoryMessage:
1538 validate.SetNullMessageText(pValue->ToWideString()); 1534 validate.SetNullMessageText(pValue->ToWideString());
1539 break; 1535 break;
1540 default: 1536 default:
1541 break; 1537 break;
1542 } 1538 }
1543 if (!bNew) { 1539 if (!bNew) {
1544 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 1540 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1545 if (!pNotify) { 1541 if (!pNotify) {
1546 return; 1542 return;
1547 } 1543 }
1548 pNotify->AddCalcValidate(this); 1544 pNotify->AddCalcValidate(this);
1549 } 1545 }
1550 } else { 1546 } else {
1551 CFX_WideString wsMessage; 1547 CFX_WideString wsMessage;
1552 switch (iMessageType) { 1548 switch (iMessageType) {
1553 case XFA_SOM_ValidationMessage: 1549 case XFA_SOM_ValidationMessage:
1554 validate.GetScriptMessageText(wsMessage); 1550 validate.GetScriptMessageText(wsMessage);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 pArguments->GetReturnValue()->SetBoolean( 2094 pArguments->GetReturnValue()->SetBoolean(
2099 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2095 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE);
2100 } 2096 }
2101 } else { 2097 } else {
2102 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); 2098 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
2103 } 2099 }
2104 } 2100 }
2105 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { 2101 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) {
2106 int32_t argc = pArguments->GetLength(); 2102 int32_t argc = pArguments->GetLength();
2107 if (argc == 0) { 2103 if (argc == 0) {
2108 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2104 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2109 if (!pNotify) { 2105 if (!pNotify) {
2110 return; 2106 return;
2111 } 2107 }
2112 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); 2108 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE);
2113 } else { 2109 } else {
2114 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 2110 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
2115 } 2111 }
2116 } 2112 }
2117 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { 2113 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) {
2118 int32_t iLength = pArguments->GetLength(); 2114 int32_t iLength = pArguments->GetLength();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 } 2181 }
2186 int32_t iIndex = pArguments->GetInt32(0); 2182 int32_t iIndex = pArguments->GetInt32(0);
2187 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); 2183 FX_BOOL bValue = pWidgetData->GetItemState(iIndex);
2188 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 2184 CFXJSE_Value* pValue = pArguments->GetReturnValue();
2189 if (pValue) 2185 if (pValue)
2190 pValue->SetBoolean(bValue); 2186 pValue->SetBoolean(bValue);
2191 } 2187 }
2192 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { 2188 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) {
2193 int32_t argc = pArguments->GetLength(); 2189 int32_t argc = pArguments->GetLength();
2194 if (argc == 0) { 2190 if (argc == 0) {
2195 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2191 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2196 if (!pNotify) { 2192 if (!pNotify) {
2197 return; 2193 return;
2198 } 2194 }
2199 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); 2195 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE);
2200 } else { 2196 } else {
2201 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2197 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2202 } 2198 }
2203 } 2199 }
2204 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} 2200 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {}
2205 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { 2201 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 } 2259 }
2264 if (iLength >= 2) { 2260 if (iLength >= 2) {
2265 CFX_ByteString bsValue = pArguments->GetUTF8String(1); 2261 CFX_ByteString bsValue = pArguments->GetUTF8String(1);
2266 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); 2262 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
2267 } 2263 }
2268 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); 2264 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE);
2269 } 2265 }
2270 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { 2266 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) {
2271 int32_t argc = pArguments->GetLength(); 2267 int32_t argc = pArguments->GetLength();
2272 if (argc == 0) { 2268 if (argc == 0) {
2273 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2269 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2274 if (!pNotify) { 2270 if (!pNotify) {
2275 pArguments->GetReturnValue()->SetBoolean(FALSE); 2271 pArguments->GetReturnValue()->SetBoolean(FALSE);
2276 } else { 2272 } else {
2277 int32_t iRet = 2273 int32_t iRet =
2278 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); 2274 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE);
2279 pArguments->GetReturnValue()->SetBoolean( 2275 pArguments->GetReturnValue()->SetBoolean(
2280 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2276 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE);
2281 } 2277 }
2282 } else { 2278 } else {
2283 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2279 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 pArguments->GetReturnValue()->SetNull(); 2348 pArguments->GetReturnValue()->SetNull();
2353 return; 2349 return;
2354 } 2350 }
2355 pArguments->GetReturnValue()->Assign( 2351 pArguments->GetReturnValue()->Assign(
2356 m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode)); 2352 m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode));
2357 } 2353 }
2358 2354
2359 void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { 2355 void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) {
2360 int32_t argc = pArguments->GetLength(); 2356 int32_t argc = pArguments->GetLength();
2361 if (argc == 0) { 2357 if (argc == 0) {
2362 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2358 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2363 if (!pNotify) { 2359 if (!pNotify) {
2364 return; 2360 return;
2365 } 2361 }
2366 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); 2362 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
2367 } else { 2363 } else {
2368 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 2364 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
2369 } 2365 }
2370 } 2366 }
2371 void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { 2367 void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) {
2372 int32_t argc = pArguments->GetLength(); 2368 int32_t argc = pArguments->GetLength();
2373 if (argc == 0) { 2369 if (argc == 0) {
2374 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2370 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2375 if (!pNotify) { 2371 if (!pNotify) {
2376 return; 2372 return;
2377 } 2373 }
2378 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 2374 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
2379 } else { 2375 } else {
2380 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2376 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2381 } 2377 }
2382 } 2378 }
2383 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { 2379 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) {
2384 int32_t argc = pArguments->GetLength(); 2380 int32_t argc = pArguments->GetLength();
2385 if (argc == 0) { 2381 if (argc == 0) {
2386 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2382 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2387 if (!pNotify) { 2383 if (!pNotify) {
2388 pArguments->GetReturnValue()->SetBoolean(FALSE); 2384 pArguments->GetReturnValue()->SetBoolean(FALSE);
2389 } else { 2385 } else {
2390 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 2386 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
2391 pArguments->GetReturnValue()->SetBoolean( 2387 pArguments->GetReturnValue()->SetBoolean(
2392 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2388 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE);
2393 } 2389 }
2394 } else { 2390 } else {
2395 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2391 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
2396 } 2392 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 CXFA_Node* pManagerNode = nullptr; 2434 CXFA_Node* pManagerNode = nullptr;
2439 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; 2435 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
2440 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { 2436 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
2441 if (pNode->GetElementType() == XFA_Element::InstanceManager) { 2437 if (pNode->GetElementType() == XFA_Element::InstanceManager) {
2442 pManagerNode = pNode; 2438 pManagerNode = pNode;
2443 break; 2439 break;
2444 } 2440 }
2445 } 2441 }
2446 if (pManagerNode) { 2442 if (pManagerNode) {
2447 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); 2443 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom);
2448 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2444 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2449 if (!pNotify) { 2445 if (!pNotify) {
2450 return; 2446 return;
2451 } 2447 }
2452 CXFA_Node* pToInstance = 2448 CXFA_Node* pToInstance =
2453 XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); 2449 XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo);
2454 if (pToInstance && 2450 if (pToInstance &&
2455 pToInstance->GetElementType() == XFA_Element::Subform) { 2451 pToInstance->GetElementType() == XFA_Element::Subform) {
2456 pNotify->RunSubformIndexChange(pToInstance); 2452 pNotify->RunSubformIndexChange(pToInstance);
2457 } 2453 }
2458 CXFA_Node* pFromInstance = 2454 CXFA_Node* pFromInstance =
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 execSingleEventByName( 2509 execSingleEventByName(
2514 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), 2510 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
2515 XFA_Element::Subform); 2511 XFA_Element::Subform);
2516 } else { 2512 } else {
2517 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); 2513 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
2518 } 2514 }
2519 } 2515 }
2520 void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { 2516 void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) {
2521 int32_t argc = pArguments->GetLength(); 2517 int32_t argc = pArguments->GetLength();
2522 if (argc == 0) { 2518 if (argc == 0) {
2523 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2519 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2524 if (!pNotify) { 2520 if (!pNotify) {
2525 return; 2521 return;
2526 } 2522 }
2527 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); 2523 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
2528 } else { 2524 } else {
2529 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 2525 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
2530 } 2526 }
2531 } 2527 }
2532 void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { 2528 void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) {
2533 int32_t argc = pArguments->GetLength(); 2529 int32_t argc = pArguments->GetLength();
2534 if (argc == 0) { 2530 if (argc == 0) {
2535 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2531 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2536 if (!pNotify) { 2532 if (!pNotify) {
2537 return; 2533 return;
2538 } 2534 }
2539 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 2535 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
2540 } else { 2536 } else {
2541 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2537 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2542 } 2538 }
2543 } 2539 }
2544 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { 2540 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) {
2545 int32_t argc = pArguments->GetLength(); 2541 int32_t argc = pArguments->GetLength();
2546 if (argc == 0) { 2542 if (argc == 0) {
2547 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 2543 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2548 if (!pNotify) { 2544 if (!pNotify) {
2549 pArguments->GetReturnValue()->SetBoolean(FALSE); 2545 pArguments->GetReturnValue()->SetBoolean(FALSE);
2550 } else { 2546 } else {
2551 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 2547 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
2552 pArguments->GetReturnValue()->SetBoolean( 2548 pArguments->GetReturnValue()->SetBoolean(
2553 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2549 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE);
2554 } 2550 }
2555 } else { 2551 } else {
2556 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2552 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
2557 } 2553 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 void CXFA_Node::Script_InstanceManager_MoveInstance( 2995 void CXFA_Node::Script_InstanceManager_MoveInstance(
3000 CFXJSE_Arguments* pArguments) { 2996 CFXJSE_Arguments* pArguments) {
3001 int32_t argc = pArguments->GetLength(); 2997 int32_t argc = pArguments->GetLength();
3002 if (argc != 2) { 2998 if (argc != 2) {
3003 pArguments->GetReturnValue()->SetUndefined(); 2999 pArguments->GetReturnValue()->SetUndefined();
3004 return; 3000 return;
3005 } 3001 }
3006 int32_t iFrom = pArguments->GetInt32(0); 3002 int32_t iFrom = pArguments->GetInt32(0);
3007 int32_t iTo = pArguments->GetInt32(1); 3003 int32_t iTo = pArguments->GetInt32(1);
3008 InstanceManager_MoveInstance(iTo, iFrom); 3004 InstanceManager_MoveInstance(iTo, iFrom);
3009 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3005 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3010 if (!pNotify) { 3006 if (!pNotify) {
3011 return; 3007 return;
3012 } 3008 }
3013 CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); 3009 CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo);
3014 if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) { 3010 if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) {
3015 pNotify->RunSubformIndexChange(pToInstance); 3011 pNotify->RunSubformIndexChange(pToInstance);
3016 } 3012 }
3017 CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); 3013 CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom);
3018 if (pFromInstance && 3014 if (pFromInstance &&
3019 pFromInstance->GetElementType() == XFA_Element::Subform) { 3015 pFromInstance->GetElementType() == XFA_Element::Subform) {
(...skipping 14 matching lines...) Expand all
3034 return; 3030 return;
3035 } 3031 }
3036 CXFA_Occur nodeOccur(GetOccurNode()); 3032 CXFA_Occur nodeOccur(GetOccurNode());
3037 int32_t iMin = nodeOccur.GetMin(); 3033 int32_t iMin = nodeOccur.GetMin();
3038 if (iCount - 1 < iMin) { 3034 if (iCount - 1 < iMin) {
3039 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min"); 3035 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min");
3040 return; 3036 return;
3041 } 3037 }
3042 CXFA_Node* pRemoveInstance = XFA_ScriptInstanceManager_GetItem(this, iIndex); 3038 CXFA_Node* pRemoveInstance = XFA_ScriptInstanceManager_GetItem(this, iIndex);
3043 XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); 3039 XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance);
3044 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3040 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3045 if (pNotify) { 3041 if (pNotify) {
3046 for (int32_t i = iIndex; i < iCount - 1; i++) { 3042 for (int32_t i = iIndex; i < iCount - 1; i++) {
3047 CXFA_Node* pSubformInstance = XFA_ScriptInstanceManager_GetItem(this, i); 3043 CXFA_Node* pSubformInstance = XFA_ScriptInstanceManager_GetItem(this, i);
3048 if (pSubformInstance && 3044 if (pSubformInstance &&
3049 pSubformInstance->GetElementType() == XFA_Element::Subform) { 3045 pSubformInstance->GetElementType() == XFA_Element::Subform) {
3050 pNotify->RunSubformIndexChange(pSubformInstance); 3046 pNotify->RunSubformIndexChange(pSubformInstance);
3051 } 3047 }
3052 } 3048 }
3053 } 3049 }
3054 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3050 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
(...skipping 30 matching lines...) Expand all
3085 if (iMax >= 0 && iCount >= iMax) { 3081 if (iMax >= 0 && iCount >= iMax) {
3086 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); 3082 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
3087 return; 3083 return;
3088 } 3084 }
3089 CXFA_Node* pNewInstance = 3085 CXFA_Node* pNewInstance =
3090 XFA_ScriptInstanceManager_CreateInstance(this, fFlags); 3086 XFA_ScriptInstanceManager_CreateInstance(this, fFlags);
3091 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, 3087 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount,
3092 FALSE); 3088 FALSE);
3093 pArguments->GetReturnValue()->Assign( 3089 pArguments->GetReturnValue()->Assign(
3094 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); 3090 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
3095 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3091 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3096 if (!pNotify) { 3092 if (!pNotify) {
3097 return; 3093 return;
3098 } 3094 }
3099 pNotify->RunNodeInitialize(pNewInstance); 3095 pNotify->RunNodeInitialize(pNewInstance);
3100 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3096 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3101 if (!pLayoutPro) { 3097 if (!pLayoutPro) {
3102 return; 3098 return;
3103 } 3099 }
3104 pLayoutPro->AddChangedContainer( 3100 pLayoutPro->AddChangedContainer(
3105 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3101 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
(...skipping 20 matching lines...) Expand all
3126 if (iMax >= 0 && iCount >= iMax) { 3122 if (iMax >= 0 && iCount >= iMax) {
3127 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); 3123 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
3128 return; 3124 return;
3129 } 3125 }
3130 CXFA_Node* pNewInstance = 3126 CXFA_Node* pNewInstance =
3131 XFA_ScriptInstanceManager_CreateInstance(this, bBind); 3127 XFA_ScriptInstanceManager_CreateInstance(this, bBind);
3132 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, 3128 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount,
3133 TRUE); 3129 TRUE);
3134 pArguments->GetReturnValue()->Assign( 3130 pArguments->GetReturnValue()->Assign(
3135 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); 3131 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
3136 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3132 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3137 if (!pNotify) { 3133 if (!pNotify) {
3138 return; 3134 return;
3139 } 3135 }
3140 pNotify->RunNodeInitialize(pNewInstance); 3136 pNotify->RunNodeInitialize(pNewInstance);
3141 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3137 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3142 if (!pLayoutPro) { 3138 if (!pLayoutPro) {
3143 return; 3139 return;
3144 } 3140 }
3145 pLayoutPro->AddChangedContainer( 3141 pLayoutPro->AddChangedContainer(
3146 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3142 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 iCount--; 3183 iCount--;
3188 } 3184 }
3189 } 3185 }
3190 } else if (iDesired > iCount) { 3186 } else if (iDesired > iCount) {
3191 while (iCount < iDesired) { 3187 while (iCount < iDesired) {
3192 CXFA_Node* pNewInstance = 3188 CXFA_Node* pNewInstance =
3193 XFA_ScriptInstanceManager_CreateInstance(this, TRUE); 3189 XFA_ScriptInstanceManager_CreateInstance(this, TRUE);
3194 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, 3190 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount,
3195 FALSE); 3191 FALSE);
3196 iCount++; 3192 iCount++;
3197 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3193 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3198 if (!pNotify) { 3194 if (!pNotify) {
3199 return 0; 3195 return 0;
3200 } 3196 }
3201 pNotify->RunNodeInitialize(pNewInstance); 3197 pNotify->RunNodeInitialize(pNewInstance);
3202 } 3198 }
3203 } 3199 }
3204 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3200 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3205 if (pLayoutPro) { 3201 if (pLayoutPro) {
3206 pLayoutPro->AddChangedContainer( 3202 pLayoutPro->AddChangedContainer(
3207 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3203 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 int32_t argc = pArguments->GetLength(); 3275 int32_t argc = pArguments->GetLength();
3280 if (argc == 0) { 3276 if (argc == 0) {
3281 m_pDocument->DoDataRemerge(TRUE); 3277 m_pDocument->DoDataRemerge(TRUE);
3282 } else { 3278 } else {
3283 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); 3279 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge");
3284 } 3280 }
3285 } 3281 }
3286 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { 3282 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) {
3287 int32_t argc = pArguments->GetLength(); 3283 int32_t argc = pArguments->GetLength();
3288 if (argc == 0) { 3284 if (argc == 0) {
3289 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3285 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3290 if (!pNotify) { 3286 if (!pNotify) {
3291 return; 3287 return;
3292 } 3288 }
3293 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); 3289 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
3294 } else { 3290 } else {
3295 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 3291 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
3296 } 3292 }
3297 } 3293 }
3298 void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { 3294 void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) {
3299 CXFA_EventParam* pEventParam = 3295 CXFA_EventParam* pEventParam =
3300 m_pDocument->GetScriptContext()->GetEventParam(); 3296 m_pDocument->GetScriptContext()->GetEventParam();
3301 if (pEventParam->m_eType == XFA_EVENT_Calculate || 3297 if (pEventParam->m_eType == XFA_EVENT_Calculate ||
3302 pEventParam->m_eType == XFA_EVENT_InitCalculate) { 3298 pEventParam->m_eType == XFA_EVENT_InitCalculate) {
3303 return; 3299 return;
3304 } 3300 }
3305 int32_t argc = pArguments->GetLength(); 3301 int32_t argc = pArguments->GetLength();
3306 if (argc == 1) { 3302 if (argc == 1) {
3307 const bool bScriptFlags = pArguments->GetInt32(0) != 0; 3303 const bool bScriptFlags = pArguments->GetInt32(0) != 0;
3308 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3304 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3309 if (!pNotify) { 3305 if (!pNotify) {
3310 return; 3306 return;
3311 } 3307 }
3312 if (bScriptFlags) { 3308 if (bScriptFlags) {
3313 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 3309 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
3314 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 3310 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
3315 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); 3311 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE);
3316 } else { 3312 } else {
3317 } 3313 }
3318 } else { 3314 } else {
3319 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); 3315 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate");
3320 } 3316 }
3321 } 3317 }
3322 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { 3318 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) {
3323 int32_t argc = pArguments->GetLength(); 3319 int32_t argc = pArguments->GetLength();
3324 if (argc == 0) { 3320 if (argc == 0) {
3325 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3321 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3326 if (!pNotify) { 3322 if (!pNotify) {
3327 return; 3323 return;
3328 } 3324 }
3329 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 3325 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
3330 } else { 3326 } else {
3331 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 3327 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
3332 } 3328 }
3333 } 3329 }
3334 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { 3330 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) {
3335 int32_t argc = pArguments->GetLength(); 3331 int32_t argc = pArguments->GetLength();
3336 if (argc == 0) { 3332 if (argc == 0) {
3337 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 3333 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3338 if (!pNotify) { 3334 if (!pNotify) {
3339 pArguments->GetReturnValue()->SetBoolean(FALSE); 3335 pArguments->GetReturnValue()->SetBoolean(FALSE);
3340 } else { 3336 } else {
3341 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 3337 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
3342 pArguments->GetReturnValue()->SetBoolean( 3338 pArguments->GetReturnValue()->SetBoolean(
3343 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 3339 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE);
3344 } 3340 }
3345 } else { 3341 } else {
3346 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 3342 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
3347 } 3343 }
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
4368 4364
4369 if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { 4365 if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) {
4370 pNode = m_pChild; 4366 pNode = m_pChild;
4371 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 4367 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
4372 const XFA_PROPERTY* pExistProperty = 4368 const XFA_PROPERTY* pExistProperty =
4373 XFA_GetPropertyOfElement(eType, pNode->GetElementType(), dwPacket); 4369 XFA_GetPropertyOfElement(eType, pNode->GetElementType(), dwPacket);
4374 if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) 4370 if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf))
4375 return nullptr; 4371 return nullptr;
4376 } 4372 }
4377 } 4373 }
4378 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); 4374
4379 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); 4375 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket);
4380 CXFA_Node* pNewNode = nullptr; 4376 CXFA_Node* pNewNode = nullptr;
4381 for (; iCount <= index; iCount++) { 4377 for (; iCount <= index; iCount++) {
4382 pNewNode = pFactory->CreateNode(pPacket, eProperty); 4378 pNewNode = m_pDocument->CreateNode(pPacket, eProperty);
4383 if (!pNewNode) 4379 if (!pNewNode)
4384 return nullptr; 4380 return nullptr;
4385 InsertChild(pNewNode, nullptr); 4381 InsertChild(pNewNode, nullptr);
4386 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); 4382 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
4387 } 4383 }
4388 return pNewNode; 4384 return pNewNode;
4389 } 4385 }
4390 int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) { 4386 int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) {
4391 CXFA_Node* pNode = m_pChild; 4387 CXFA_Node* pNode = m_pChild;
4392 int32_t iCount = 0; 4388 int32_t iCount = 0;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4455 pNode->m_pNext = pPrev->m_pNext; 4451 pNode->m_pNext = pPrev->m_pNext;
4456 pPrev->m_pNext = pNode; 4452 pPrev->m_pNext = pNode;
4457 index = iCount; 4453 index = iCount;
4458 } 4454 }
4459 if (!pNode->m_pNext) { 4455 if (!pNode->m_pNext) {
4460 m_pLastChild = pNode; 4456 m_pLastChild = pNode;
4461 } 4457 }
4462 ASSERT(m_pLastChild); 4458 ASSERT(m_pLastChild);
4463 ASSERT(!m_pLastChild->m_pNext); 4459 ASSERT(!m_pLastChild->m_pNext);
4464 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); 4460 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren);
4465 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4461 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4466 if (pNotify) 4462 if (pNotify)
4467 pNotify->OnChildAdded(this); 4463 pNotify->OnChildAdded(this);
4468 4464
4469 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { 4465 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
4470 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); 4466 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent));
4471 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); 4467 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index);
4472 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); 4468 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode);
4473 } 4469 }
4474 return index; 4470 return index;
4475 } 4471 }
(...skipping 26 matching lines...) Expand all
4502 } 4498 }
4503 pNode->m_pNext = pPrev->m_pNext; 4499 pNode->m_pNext = pPrev->m_pNext;
4504 pPrev->m_pNext = pNode; 4500 pPrev->m_pNext = pNode;
4505 } 4501 }
4506 if (!pNode->m_pNext) { 4502 if (!pNode->m_pNext) {
4507 m_pLastChild = pNode; 4503 m_pLastChild = pNode;
4508 } 4504 }
4509 ASSERT(m_pLastChild); 4505 ASSERT(m_pLastChild);
4510 ASSERT(!m_pLastChild->m_pNext); 4506 ASSERT(!m_pLastChild->m_pNext);
4511 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); 4507 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren);
4512 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4508 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4513 if (pNotify) 4509 if (pNotify)
4514 pNotify->OnChildAdded(this); 4510 pNotify->OnChildAdded(this);
4515 4511
4516 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { 4512 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
4517 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); 4513 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent));
4518 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); 4514 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex);
4519 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); 4515 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode);
4520 } 4516 }
4521 return TRUE; 4517 return TRUE;
4522 } 4518 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const { 4677 bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const {
4682 if (m_uNodeFlags & dwFlag) 4678 if (m_uNodeFlags & dwFlag)
4683 return true; 4679 return true;
4684 if (dwFlag == XFA_NodeFlag_HasRemovedChildren) 4680 if (dwFlag == XFA_NodeFlag_HasRemovedChildren)
4685 return m_pParent && m_pParent->HasFlag(dwFlag); 4681 return m_pParent && m_pParent->HasFlag(dwFlag);
4686 return false; 4682 return false;
4687 } 4683 }
4688 4684
4689 void CXFA_Node::SetFlag(uint32_t dwFlag, bool bNotify) { 4685 void CXFA_Node::SetFlag(uint32_t dwFlag, bool bNotify) {
4690 if (dwFlag == XFA_NodeFlag_Initialized && bNotify && !IsInitialized()) { 4686 if (dwFlag == XFA_NodeFlag_Initialized && bNotify && !IsInitialized()) {
4691 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4687 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4692 if (pNotify) { 4688 if (pNotify) {
4693 pNotify->OnNodeReady(this); 4689 pNotify->OnNodeReady(this);
4694 } 4690 }
4695 } 4691 }
4696 m_uNodeFlags |= dwFlag; 4692 m_uNodeFlags |= dwFlag;
4697 } 4693 }
4698 4694
4699 void CXFA_Node::ClearFlag(uint32_t dwFlag) { 4695 void CXFA_Node::ClearFlag(uint32_t dwFlag) {
4700 m_uNodeFlags &= ~dwFlag; 4696 m_uNodeFlags &= ~dwFlag;
4701 } 4697 }
4702 4698
4703 FX_BOOL CXFA_Node::IsAttributeInXML() { 4699 FX_BOOL CXFA_Node::IsAttributeInXML() {
4704 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; 4700 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData;
4705 } 4701 }
4706 4702
4707 void CXFA_Node::OnRemoved(bool bNotify) { 4703 void CXFA_Node::OnRemoved(bool bNotify) {
4708 if (!bNotify) 4704 if (!bNotify)
4709 return; 4705 return;
4710 4706
4711 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4707 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4712 if (pNotify) 4708 if (pNotify)
4713 pNotify->OnChildRemoved(); 4709 pNotify->OnChildRemoved();
4714 } 4710 }
4715 4711
4716 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) { 4712 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) {
4717 if (bNotify && IsInitialized()) { 4713 if (bNotify && IsInitialized()) {
4718 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4714 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4719 if (pNotify) { 4715 if (pNotify) {
4720 pNotify->OnValueChanging(this, eAttr); 4716 pNotify->OnValueChanging(this, eAttr);
4721 } 4717 }
4722 } 4718 }
4723 } 4719 }
4724 4720
4725 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, 4721 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr,
4726 bool bNotify, 4722 bool bNotify,
4727 FX_BOOL bScriptModify) { 4723 FX_BOOL bScriptModify) {
4728 if (bNotify && IsInitialized()) { 4724 if (bNotify && IsInitialized()) {
4729 Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify); 4725 Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify);
4730 } 4726 }
4731 } 4727 }
4732 4728
4733 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, 4729 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName,
4734 XFA_Element eType) { 4730 XFA_Element eType) {
4735 int32_t iRet = XFA_EVENTERROR_NotExist; 4731 int32_t iRet = XFA_EVENTERROR_NotExist;
4736 const XFA_ExecEventParaInfo* eventParaInfo = 4732 const XFA_ExecEventParaInfo* eventParaInfo =
4737 GetEventParaInfoByName(wsEventName); 4733 GetEventParaInfoByName(wsEventName);
4738 if (eventParaInfo) { 4734 if (eventParaInfo) {
4739 uint32_t validFlags = eventParaInfo->m_validFlags; 4735 uint32_t validFlags = eventParaInfo->m_validFlags;
4740 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 4736 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4741 if (!pNotify) { 4737 if (!pNotify) {
4742 return iRet; 4738 return iRet;
4743 } 4739 }
4744 if (validFlags == 1) { 4740 if (validFlags == 1) {
4745 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType); 4741 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType);
4746 } else if (validFlags == 2) { 4742 } else if (validFlags == 2) {
4747 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4743 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4748 FALSE, FALSE); 4744 FALSE, FALSE);
4749 } else if (validFlags == 3) { 4745 } else if (validFlags == 3) {
4750 if (eType == XFA_Element::Subform) { 4746 if (eType == XFA_Element::Subform) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
5259 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); 5255 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode);
5260 } 5256 }
5261 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { 5257 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
5262 return m_pAttachNode->RemoveChild(pNode); 5258 return m_pAttachNode->RemoveChild(pNode);
5263 } 5259 }
5264 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { 5260 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
5265 return m_pAttachNode->GetChild( 5261 return m_pAttachNode->GetChild(
5266 iIndex, XFA_Element::Unknown, 5262 iIndex, XFA_Element::Unknown,
5267 m_pAttachNode->GetElementType() == XFA_Element::Subform); 5263 m_pAttachNode->GetElementType() == XFA_Element::Subform);
5268 } 5264 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_localevalue.cpp ('k') | xfa/fxfa/parser/xfa_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698