OLD | NEW |
---|---|
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 "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 } | 1291 } |
1292 void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, | 1292 void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, |
1293 FX_BOOL bSetting, | 1293 FX_BOOL bSetting, |
1294 XFA_ATTRIBUTE eAttribute) { | 1294 XFA_ATTRIBUTE eAttribute) { |
1295 if (!bSetting) { | 1295 if (!bSetting) { |
1296 FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); | 1296 FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); |
1297 } else { | 1297 } else { |
1298 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1298 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
1299 } | 1299 } |
1300 } | 1300 } |
1301 | |
1301 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( | 1302 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
1302 void* eAttribute, | 1303 XFA_ATTRIBUTE eAttribute, |
1303 void* eValue, | |
1304 FX_BOOL bScriptModify) { | 1304 FX_BOOL bScriptModify) { |
1305 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 1305 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
1306 if (!pLayoutPro) { | 1306 if (!pLayoutPro) |
1307 return; | |
1308 | |
1309 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | |
1310 if (!pNotify) | |
1311 return; | |
1312 | |
1313 uint32_t dwPacket = GetPacketID(); | |
1314 if (!(dwPacket & XFA_XDPPACKET_Form)) { | |
1315 pNotify->OnValueChanged(this, eAttribute, this, this); | |
1307 return; | 1316 return; |
1308 } | 1317 } |
1309 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 1318 |
1310 if (!pNotify) { | 1319 bool bNeedFindContainer = false; |
1311 return; | 1320 XFA_ELEMENT eType = GetClassID(); |
1312 } | 1321 switch (eType) { |
1313 uint32_t dwPacket = GetPacketID(); | 1322 case XFA_ELEMENT_Caption: |
1314 if (dwPacket & XFA_XDPPACKET_Form) { | 1323 bNeedFindContainer = true; |
1315 FX_BOOL bNeedFindContainer = FALSE; | 1324 pNotify->OnValueChanged(this, eAttribute, this, |
1316 XFA_ELEMENT eType = GetClassID(); | 1325 GetNodeItem(XFA_NODEITEM_Parent)); |
1317 switch (eType) { | 1326 break; |
1318 case XFA_ELEMENT_Caption: | 1327 case XFA_ELEMENT_Font: |
1319 bNeedFindContainer = TRUE; | 1328 case XFA_ELEMENT_Para: { |
1320 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | 1329 bNeedFindContainer = true; |
1321 eValue, this, GetNodeItem(XFA_NODEITEM_Parent)); | 1330 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
1322 break; | 1331 if (pParentNode->GetClassID() == XFA_ELEMENT_Caption) { |
1323 case XFA_ELEMENT_Font: | 1332 pNotify->OnValueChanged(this, eAttribute, pParentNode, |
1324 case XFA_ELEMENT_Para: { | 1333 pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); |
1325 bNeedFindContainer = TRUE; | 1334 } else { |
1326 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 1335 pNotify->OnValueChanged(this, eAttribute, this, pParentNode); |
1327 if (pParentNode->GetClassID() == XFA_ELEMENT_Caption) { | 1336 } |
1328 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | 1337 } break; |
1329 eValue, pParentNode, | 1338 case XFA_ELEMENT_Margin: { |
1330 pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); | 1339 bNeedFindContainer = true; |
1340 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | |
1341 XFA_ELEMENT eParentType = pParentNode->GetClassID(); | |
1342 if (pParentNode->IsContainerNode()) { | |
1343 pNotify->OnValueChanged(this, eAttribute, this, pParentNode); | |
1344 } else if (eParentType == XFA_ELEMENT_Caption) { | |
1345 pNotify->OnValueChanged(this, eAttribute, pParentNode, | |
1346 pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1347 } else { | |
1348 CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1349 if (pNode && pNode->GetClassID() == XFA_ELEMENT_Ui) { | |
1350 pNotify->OnValueChanged(this, eAttribute, pNode, | |
1351 pNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1352 } | |
1353 } | |
1354 } break; | |
1355 case XFA_ELEMENT_Comb: { | |
1356 CXFA_Node* pEditNode = GetNodeItem(XFA_NODEITEM_Parent); | |
1357 XFA_ELEMENT eUIType = pEditNode->GetClassID(); | |
1358 if (pEditNode && (eUIType == XFA_ELEMENT_DateTimeEdit || | |
1359 eUIType == XFA_ELEMENT_NumericEdit || | |
1360 eUIType == XFA_ELEMENT_TextEdit)) { | |
1361 CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1362 if (pUINode) { | |
1363 pNotify->OnValueChanged(this, eAttribute, pUINode, | |
1364 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1365 } | |
1366 } | |
1367 } break; | |
1368 case XFA_ELEMENT_Button: | |
1369 case XFA_ELEMENT_Barcode: | |
1370 case XFA_ELEMENT_ChoiceList: | |
1371 case XFA_ELEMENT_DateTimeEdit: | |
1372 case XFA_ELEMENT_NumericEdit: | |
1373 case XFA_ELEMENT_PasswordEdit: | |
1374 case XFA_ELEMENT_TextEdit: { | |
1375 CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); | |
1376 if (pUINode) { | |
1377 pNotify->OnValueChanged(this, eAttribute, pUINode, | |
1378 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1379 } | |
1380 } break; | |
1381 case XFA_ELEMENT_CheckButton: { | |
1382 bNeedFindContainer = true; | |
1383 CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); | |
1384 if (pUINode) { | |
1385 pNotify->OnValueChanged(this, eAttribute, pUINode, | |
1386 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1387 } | |
1388 } break; | |
1389 case XFA_ELEMENT_Keep: | |
1390 case XFA_ELEMENT_Bookend: | |
1391 case XFA_ELEMENT_Break: | |
1392 case XFA_ELEMENT_BreakAfter: | |
1393 case XFA_ELEMENT_BreakBefore: | |
1394 case XFA_ELEMENT_Overflow: | |
1395 bNeedFindContainer = true; | |
1396 break; | |
1397 case XFA_ELEMENT_Area: | |
1398 case XFA_ELEMENT_Draw: | |
1399 case XFA_ELEMENT_ExclGroup: | |
1400 case XFA_ELEMENT_Field: | |
1401 case XFA_ELEMENT_Subform: | |
1402 case XFA_ELEMENT_SubformSet: | |
1403 pLayoutPro->AddChangedContainer(this); | |
1404 pNotify->OnValueChanged(this, eAttribute, this, this); | |
1405 break; | |
1406 case XFA_ELEMENT_Sharptext: | |
1407 case XFA_ELEMENT_Sharpxml: | |
1408 case XFA_ELEMENT_SharpxHTML: { | |
1409 CXFA_Node* pTextNode = GetNodeItem(XFA_NODEITEM_Parent); | |
1410 if (!pTextNode) { | |
1411 return; | |
1412 } | |
1413 CXFA_Node* pValueNode = pTextNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1414 if (!pValueNode) { | |
1415 return; | |
1416 } | |
1417 XFA_ELEMENT eType = pValueNode->GetClassID(); | |
1418 if (eType == XFA_ELEMENT_Value) { | |
1419 bNeedFindContainer = true; | |
1420 CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1421 if (pNode && pNode->IsContainerNode()) { | |
1422 if (bScriptModify) { | |
1423 pValueNode = pNode; | |
1424 } | |
1425 pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); | |
1331 } else { | 1426 } else { |
1332 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | 1427 pNotify->OnValueChanged(this, eAttribute, pNode, |
1333 eValue, this, pParentNode); | 1428 pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
1334 } | 1429 } |
1335 } break; | 1430 } else { |
1336 case XFA_ELEMENT_Margin: { | 1431 if (eType == XFA_ELEMENT_Items) { |
1337 bNeedFindContainer = TRUE; | 1432 CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); |
1338 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 1433 if (pNode && pNode->IsContainerNode()) { |
1339 XFA_ELEMENT eParentType = pParentNode->GetClassID(); | 1434 pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); |
1340 if (pParentNode->IsContainerNode()) { | |
1341 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1342 eValue, this, pParentNode); | |
1343 } else if (eParentType == XFA_ELEMENT_Caption) { | |
1344 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1345 eValue, pParentNode, | |
1346 pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1347 } else { | |
1348 CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1349 if (pNode && pNode->GetClassID() == XFA_ELEMENT_Ui) { | |
1350 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1351 eValue, pNode, | |
1352 pNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1353 } | 1435 } |
1354 } | 1436 } |
1355 } break; | 1437 } |
1356 case XFA_ELEMENT_Comb: { | 1438 } break; |
1357 CXFA_Node* pEditNode = GetNodeItem(XFA_NODEITEM_Parent); | 1439 default: |
1358 XFA_ELEMENT eUIType = pEditNode->GetClassID(); | 1440 break; |
1359 if (pEditNode && (eUIType == XFA_ELEMENT_DateTimeEdit || | 1441 } |
1360 eUIType == XFA_ELEMENT_NumericEdit || | 1442 if (bNeedFindContainer) { |
1361 eUIType == XFA_ELEMENT_TextEdit)) { | 1443 CXFA_Node* pParent = this; |
1362 CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent); | 1444 while (pParent) { |
1363 if (pUINode) { | 1445 if (pParent->IsContainerNode()) { |
1364 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1365 eValue, pUINode, | |
1366 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1367 } | |
1368 } | |
1369 } break; | |
1370 case XFA_ELEMENT_Button: | |
1371 case XFA_ELEMENT_Barcode: | |
1372 case XFA_ELEMENT_ChoiceList: | |
1373 case XFA_ELEMENT_DateTimeEdit: | |
1374 case XFA_ELEMENT_NumericEdit: | |
1375 case XFA_ELEMENT_PasswordEdit: | |
1376 case XFA_ELEMENT_TextEdit: { | |
1377 CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); | |
1378 if (pUINode) { | |
1379 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1380 eValue, pUINode, | |
1381 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1382 } | |
1383 } break; | |
1384 case XFA_ELEMENT_CheckButton: { | |
1385 bNeedFindContainer = TRUE; | |
1386 CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); | |
1387 if (pUINode) { | |
1388 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1389 eValue, pUINode, | |
1390 pUINode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1391 } | |
1392 } break; | |
1393 case XFA_ELEMENT_Keep: | |
1394 case XFA_ELEMENT_Bookend: | |
1395 case XFA_ELEMENT_Break: | |
1396 case XFA_ELEMENT_BreakAfter: | |
1397 case XFA_ELEMENT_BreakBefore: | |
1398 case XFA_ELEMENT_Overflow: | |
1399 bNeedFindContainer = TRUE; | |
1400 break; | 1446 break; |
1401 case XFA_ELEMENT_Area: | 1447 } |
1402 case XFA_ELEMENT_Draw: | 1448 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); |
1403 case XFA_ELEMENT_ExclGroup: | |
1404 case XFA_ELEMENT_Field: | |
1405 case XFA_ELEMENT_Subform: | |
1406 case XFA_ELEMENT_SubformSet: | |
1407 pLayoutPro->AddChangedContainer(this); | |
1408 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1409 eValue, this, this); | |
1410 break; | |
1411 case XFA_ELEMENT_Sharptext: | |
1412 case XFA_ELEMENT_Sharpxml: | |
1413 case XFA_ELEMENT_SharpxHTML: { | |
1414 CXFA_Node* pTextNode = GetNodeItem(XFA_NODEITEM_Parent); | |
1415 if (!pTextNode) { | |
1416 return; | |
1417 } | |
1418 CXFA_Node* pValueNode = pTextNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1419 if (!pValueNode) { | |
1420 return; | |
1421 } | |
1422 XFA_ELEMENT eType = pValueNode->GetClassID(); | |
1423 if (eType == XFA_ELEMENT_Value) { | |
1424 bNeedFindContainer = TRUE; | |
1425 CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1426 if (pNode && pNode->IsContainerNode()) { | |
1427 if (bScriptModify) { | |
1428 pValueNode = pNode; | |
1429 } | |
1430 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1431 eValue, pValueNode, pNode); | |
1432 } else { | |
1433 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1434 eValue, pNode, | |
1435 pNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
1436 } | |
1437 } else { | |
1438 if (eType == XFA_ELEMENT_Items) { | |
1439 CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1440 if (pNode && pNode->IsContainerNode()) { | |
1441 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, | |
1442 eValue, pValueNode, pNode); | |
1443 } | |
1444 } | |
1445 } | |
1446 } break; | |
1447 default: | |
1448 break; | |
1449 } | 1449 } |
1450 if (bNeedFindContainer) { | 1450 if (pParent) { |
1451 CXFA_Node* pParent = this; | 1451 pLayoutPro->AddChangedContainer(pParent); |
1452 while (pParent) { | |
1453 if (pParent->IsContainerNode()) { | |
1454 break; | |
1455 } | |
1456 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); | |
1457 } | |
1458 if (pParent) { | |
1459 pLayoutPro->AddChangedContainer(pParent); | |
1460 } | |
1461 } | 1452 } |
1462 } else { | |
1463 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, eValue, | |
1464 this, this); | |
1465 } | 1453 } |
1466 } | 1454 } |
1455 | |
1467 void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue, | 1456 void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue, |
1468 FX_BOOL bSetting, | 1457 FX_BOOL bSetting, |
1469 XFA_ATTRIBUTE eAttribute) { | 1458 XFA_ATTRIBUTE eAttribute) { |
1470 if (bSetting) { | 1459 if (bSetting) { |
1471 CFX_ByteString szValue; | 1460 CFX_ByteString szValue; |
1472 FXJSE_Value_ToUTF8String(hValue, szValue); | 1461 FXJSE_Value_ToUTF8String(hValue, szValue); |
1473 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 1462 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
1474 SetAttribute(eAttribute, wsValue.AsStringC(), TRUE); | 1463 SetAttribute(eAttribute, wsValue.AsStringC(), TRUE); |
1475 if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { | 1464 if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { |
1476 CFX_WideString wsUseVal = wsValue, wsID, wsSOM; | 1465 CFX_WideString wsUseVal = wsValue, wsID, wsSOM; |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3747 void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) { | 3736 void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) { |
3748 return (void*)(uintptr_t)((eElement << 16) | (eAttribute << 8) | | 3737 return (void*)(uintptr_t)((eElement << 16) | (eAttribute << 8) | |
3749 XFA_KEYTYPE_Element); | 3738 XFA_KEYTYPE_Element); |
3750 } | 3739 } |
3751 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { | 3740 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { |
3752 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3741 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
3753 return HasMapModuleKey(pKey, bCanInherit); | 3742 return HasMapModuleKey(pKey, bCanInherit); |
3754 } | 3743 } |
3755 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, | 3744 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, |
3756 const CFX_WideStringC& wsValue, | 3745 const CFX_WideStringC& wsValue, |
3757 FX_BOOL bNotify) { | 3746 bool bNotify) { |
3758 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); | 3747 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); |
3759 if (pAttr == NULL) { | 3748 if (pAttr == NULL) { |
3760 return FALSE; | 3749 return FALSE; |
3761 } | 3750 } |
3762 XFA_ATTRIBUTETYPE eType = pAttr->eType; | 3751 XFA_ATTRIBUTETYPE eType = pAttr->eType; |
3763 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { | 3752 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { |
3764 const XFA_NOTSUREATTRIBUTE* pNotsure = | 3753 const XFA_NOTSUREATTRIBUTE* pNotsure = |
3765 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); | 3754 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); |
3766 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; | 3755 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; |
3767 } | 3756 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3843 mValue.ToString(wsValue); | 3832 mValue.ToString(wsValue); |
3844 return TRUE; | 3833 return TRUE; |
3845 } break; | 3834 } break; |
3846 default: | 3835 default: |
3847 break; | 3836 break; |
3848 } | 3837 } |
3849 return FALSE; | 3838 return FALSE; |
3850 } | 3839 } |
3851 FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, | 3840 FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, |
3852 const CFX_WideStringC& wsValue, | 3841 const CFX_WideStringC& wsValue, |
3853 FX_BOOL bNotify) { | 3842 bool bNotify) { |
3854 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); | 3843 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); |
3855 if (pAttributeInfo) { | 3844 if (pAttributeInfo) { |
3856 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); | 3845 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); |
3857 } | 3846 } |
3858 void* pKey = XFA_GetMapKey_Custom(wsAttr); | 3847 void* pKey = XFA_GetMapKey_Custom(wsAttr); |
3859 SetMapModuleString(pKey, wsValue); | 3848 SetMapModuleString(pKey, wsValue); |
3860 return TRUE; | 3849 return TRUE; |
3861 } | 3850 } |
3862 FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, | 3851 FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, |
3863 CFX_WideString& wsValue, | 3852 CFX_WideString& wsValue, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3901 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, | 3890 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, |
3902 XFA_ATTRIBUTEENUM& eValue, | 3891 XFA_ATTRIBUTEENUM& eValue, |
3903 FX_BOOL bUseDefault) { | 3892 FX_BOOL bUseDefault) { |
3904 void* pValue = NULL; | 3893 void* pValue = NULL; |
3905 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) { | 3894 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) { |
3906 return FALSE; | 3895 return FALSE; |
3907 } | 3896 } |
3908 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; | 3897 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; |
3909 return TRUE; | 3898 return TRUE; |
3910 } | 3899 } |
3900 | |
3911 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, | 3901 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, |
3912 CXFA_Measurement mValue, | 3902 CXFA_Measurement mValue, |
3913 FX_BOOL bNotify) { | 3903 bool bNotify) { |
3914 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3904 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
3915 OnChanging(eAttr, &mValue, bNotify); | 3905 OnChanging(eAttr, bNotify); |
3916 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); | 3906 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); |
3917 OnChanged(eAttr, &mValue, bNotify); | 3907 OnChanged(eAttr, bNotify, FALSE); |
3918 return TRUE; | 3908 return TRUE; |
3919 } | 3909 } |
3910 | |
3920 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, | 3911 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, |
3921 CXFA_Measurement& mValue, | 3912 CXFA_Measurement& mValue, |
3922 FX_BOOL bUseDefault) const { | 3913 FX_BOOL bUseDefault) const { |
3923 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3914 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
3924 void* pValue; | 3915 void* pValue; |
3925 int32_t iBytes; | 3916 int32_t iBytes; |
3926 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { | 3917 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { |
3927 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); | 3918 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); |
3928 return TRUE; | 3919 return TRUE; |
3929 } | 3920 } |
3930 if (bUseDefault && | 3921 if (bUseDefault && |
3931 XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, | 3922 XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, |
3932 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { | 3923 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { |
3933 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); | 3924 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); |
3934 return TRUE; | 3925 return TRUE; |
3935 } | 3926 } |
3936 return FALSE; | 3927 return FALSE; |
3937 } | 3928 } |
3938 | 3929 |
3939 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { | 3930 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { |
3940 CXFA_Measurement mValue; | 3931 CXFA_Measurement mValue; |
3941 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); | 3932 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); |
3942 } | 3933 } |
3943 | 3934 |
3944 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, | 3935 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, |
3945 const CFX_WideString& wsValue, | 3936 const CFX_WideString& wsValue, |
3946 FX_BOOL bNotify, | 3937 bool bNotify, |
3947 FX_BOOL bScriptModify) { | 3938 FX_BOOL bScriptModify) { |
3948 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3939 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
3949 OnChanging(eAttr, (void*)wsValue.c_str(), bNotify); | 3940 OnChanging(eAttr, bNotify); |
3950 if (eAttr == XFA_ATTRIBUTE_Value) { | 3941 if (eAttr == XFA_ATTRIBUTE_Value) { |
3951 CFX_WideString* pClone = new CFX_WideString(wsValue); | 3942 CFX_WideString* pClone = new CFX_WideString(wsValue); |
3952 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 3943 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
3953 } else { | 3944 } else { |
3954 SetMapModuleString(pKey, wsValue.AsStringC()); | 3945 SetMapModuleString(pKey, wsValue.AsStringC()); |
3955 if (eAttr == XFA_ATTRIBUTE_Name) | 3946 if (eAttr == XFA_ATTRIBUTE_Name) |
3956 UpdateNameHash(); | 3947 UpdateNameHash(); |
3957 } | 3948 } |
3958 OnChanged(eAttr, (void*)wsValue.c_str(), bNotify, bScriptModify); | 3949 OnChanged(eAttr, bNotify, bScriptModify); |
3959 if (IsNeedSavingXMLNode() && eAttr != XFA_ATTRIBUTE_QualifiedName && | 3950 |
3960 eAttr != XFA_ATTRIBUTE_BindingNode) { | 3951 if (!IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName || |
3961 if (eAttr == XFA_ATTRIBUTE_Name && | 3952 eAttr == XFA_ATTRIBUTE_BindingNode) { |
3962 (m_eNodeClass == XFA_ELEMENT_DataValue || | 3953 return TRUE; |
3963 m_eNodeClass == XFA_ELEMENT_DataGroup)) { | 3954 } |
3964 return TRUE; | 3955 |
3965 } | 3956 if (eAttr == XFA_ATTRIBUTE_Name && (m_eNodeClass == XFA_ELEMENT_DataValue || |
3966 if (eAttr == XFA_ATTRIBUTE_Value) { | 3957 m_eNodeClass == XFA_ELEMENT_DataGroup)) { |
3967 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); | 3958 return TRUE; |
3968 switch (eXMLType) { | 3959 } |
3969 case FDE_XMLNODE_Element: | 3960 |
3970 if (IsAttributeInXML()) { | 3961 if (eAttr == XFA_ATTRIBUTE_Value) { |
3971 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 3962 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
3972 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsValue); | 3963 switch (eXMLType) { |
3973 } else { | 3964 case FDE_XMLNODE_Element: |
3974 FX_BOOL bDeleteChildren = TRUE; | 3965 if (IsAttributeInXML()) { |
3975 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 3966 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
3976 for (CXFA_Node* pChildDataNode = | 3967 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsValue); |
3977 GetNodeItem(XFA_NODEITEM_FirstChild); | 3968 } else { |
3978 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( | 3969 FX_BOOL bDeleteChildren = TRUE; |
3979 XFA_NODEITEM_NextSibling)) { | 3970 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
3980 CXFA_NodeArray formNodes; | 3971 for (CXFA_Node* pChildDataNode = |
3981 if (pChildDataNode->GetBindItems(formNodes) > 0) { | 3972 GetNodeItem(XFA_NODEITEM_FirstChild); |
3982 bDeleteChildren = FALSE; | 3973 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( |
3983 break; | 3974 XFA_NODEITEM_NextSibling)) { |
3984 } | 3975 CXFA_NodeArray formNodes; |
3976 if (pChildDataNode->GetBindItems(formNodes) > 0) { | |
3977 bDeleteChildren = FALSE; | |
3978 break; | |
3985 } | 3979 } |
3986 } | 3980 } |
3987 if (bDeleteChildren) { | |
3988 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren(); | |
3989 } | |
3990 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue); | |
3991 } | 3981 } |
3992 break; | 3982 if (bDeleteChildren) { |
3993 case FDE_XMLNODE_Text: | 3983 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren(); |
3994 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue); | 3984 } |
3995 break; | 3985 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue); |
3996 default: | 3986 } |
3997 FXSYS_assert(0); | 3987 break; |
3998 } | 3988 case FDE_XMLNODE_Text: |
3999 return TRUE; | 3989 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue); |
3990 break; | |
3991 default: | |
3992 FXSYS_assert(0); | |
4000 } | 3993 } |
4001 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); | 3994 return TRUE; |
4002 if (pInfo) { | 3995 } |
4003 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 3996 |
4004 CFX_WideString wsAttrName = pInfo->pName; | 3997 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); |
4005 if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { | 3998 if (pInfo) { |
4006 wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName; | 3999 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
4007 } | 4000 CFX_WideString wsAttrName = pInfo->pName; |
4008 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); | 4001 if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { |
4002 wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName; | |
4009 } | 4003 } |
4004 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); | |
4010 } | 4005 } |
4011 return TRUE; | 4006 return TRUE; |
4012 } | 4007 } |
4008 | |
4013 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, | 4009 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, |
4014 const CFX_WideString& wsXMLValue, | 4010 const CFX_WideString& wsXMLValue, |
4015 FX_BOOL bNotify, | 4011 bool bNotify, |
4016 FX_BOOL bScriptModify) { | 4012 FX_BOOL bScriptModify) { |
4017 void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); | 4013 void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); |
4018 OnChanging(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify); | 4014 OnChanging(XFA_ATTRIBUTE_Value, bNotify); |
4019 CFX_WideString* pClone = new CFX_WideString(wsValue); | 4015 CFX_WideString* pClone = new CFX_WideString(wsValue); |
4020 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 4016 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
4021 OnChanged(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify, | 4017 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); |
4022 bScriptModify); | |
4023 if (IsNeedSavingXMLNode()) { | 4018 if (IsNeedSavingXMLNode()) { |
4024 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); | 4019 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
4025 switch (eXMLType) { | 4020 switch (eXMLType) { |
4026 case FDE_XMLNODE_Element: | 4021 case FDE_XMLNODE_Element: |
4027 if (IsAttributeInXML()) { | 4022 if (IsAttributeInXML()) { |
4028 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4023 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
4029 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); | 4024 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); |
4030 } else { | 4025 } else { |
4031 FX_BOOL bDeleteChildren = TRUE; | 4026 FX_BOOL bDeleteChildren = TRUE; |
4032 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 4027 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4119 return SetUserData(pKey, pData, pCallbackInfo); | 4114 return SetUserData(pKey, pData, pCallbackInfo); |
4120 } | 4115 } |
4121 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { | 4116 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { |
4122 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4117 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
4123 pData = GetUserData(pKey); | 4118 pData = GetUserData(pKey); |
4124 return pData != NULL; | 4119 return pData != NULL; |
4125 } | 4120 } |
4126 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, | 4121 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, |
4127 XFA_ATTRIBUTETYPE eType, | 4122 XFA_ATTRIBUTETYPE eType, |
4128 void* pValue, | 4123 void* pValue, |
4129 FX_BOOL bNotify) { | 4124 bool bNotify) { |
4130 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4125 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
4131 OnChanging(eAttr, pValue, bNotify); | 4126 OnChanging(eAttr, bNotify); |
4132 SetMapModuleValue(pKey, pValue); | 4127 SetMapModuleValue(pKey, pValue); |
4133 OnChanged(eAttr, pValue, bNotify); | 4128 OnChanged(eAttr, bNotify, FALSE); |
4134 if (IsNeedSavingXMLNode()) { | 4129 if (IsNeedSavingXMLNode()) { |
4135 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 4130 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
4136 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); | 4131 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); |
4137 if (pInfo) { | 4132 if (pInfo) { |
4138 switch (eType) { | 4133 switch (eType) { |
4139 case XFA_ATTRIBUTETYPE_Enum: | 4134 case XFA_ATTRIBUTETYPE_Enum: |
4140 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4135 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
4141 ->SetString( | 4136 ->SetString( |
4142 pInfo->pName, | 4137 pInfo->pName, |
4143 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) | 4138 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4185 } | 4180 } |
4186 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { | 4181 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { |
4187 int32_t iBytes = 0; | 4182 int32_t iBytes = 0; |
4188 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { | 4183 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { |
4189 return FALSE; | 4184 return FALSE; |
4190 } | 4185 } |
4191 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); | 4186 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); |
4192 } | 4187 } |
4193 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, | 4188 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, |
4194 const CFX_WideString& wsXMLValue, | 4189 const CFX_WideString& wsXMLValue, |
4195 FX_BOOL bNotify, | 4190 bool bNotify, |
4196 FX_BOOL bScriptModify, | 4191 FX_BOOL bScriptModify, |
4197 FX_BOOL bSyncData) { | 4192 FX_BOOL bSyncData) { |
4198 CXFA_Node* pNode = NULL; | 4193 CXFA_Node* pNode = NULL; |
4199 CXFA_Node* pBindNode = NULL; | 4194 CXFA_Node* pBindNode = NULL; |
4200 switch (GetObjectType()) { | 4195 switch (GetObjectType()) { |
4201 case XFA_OBJECTTYPE_ContainerNode: { | 4196 case XFA_OBJECTTYPE_ContainerNode: { |
4202 if (XFA_FieldIsMultiListBox(this)) { | 4197 if (XFA_FieldIsMultiListBox(this)) { |
4203 CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); | 4198 CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); |
4204 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); | 4199 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); |
4205 FXSYS_assert(pChildValue); | 4200 FXSYS_assert(pChildValue); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4361 pNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, | 4356 pNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, |
4362 FALSE); | 4357 FALSE); |
4363 } | 4358 } |
4364 } | 4359 } |
4365 return TRUE; | 4360 return TRUE; |
4366 } | 4361 } |
4367 return FALSE; | 4362 return FALSE; |
4368 } | 4363 } |
4369 FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, | 4364 FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, |
4370 const CFX_WideString& wsXMLValue, | 4365 const CFX_WideString& wsXMLValue, |
4371 FX_BOOL bNotify, | 4366 bool bNotify, |
4372 FX_BOOL bScriptModify, | 4367 FX_BOOL bScriptModify, |
4373 FX_BOOL bSyncData) { | 4368 FX_BOOL bSyncData) { |
4374 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, | 4369 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, |
4375 bSyncData); | 4370 bSyncData); |
4376 } | 4371 } |
4377 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { | 4372 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { |
4378 CFX_WideString wsContent; | 4373 CFX_WideString wsContent; |
4379 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); | 4374 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); |
4380 } | 4375 } |
4381 CFX_WideString CXFA_Node::GetContent() { | 4376 CFX_WideString CXFA_Node::GetContent() { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4613 pPrev->m_pNext = pNode; | 4608 pPrev->m_pNext = pNode; |
4614 index = iCount; | 4609 index = iCount; |
4615 } | 4610 } |
4616 if (pNode->m_pNext == NULL) { | 4611 if (pNode->m_pNext == NULL) { |
4617 m_pLastChild = pNode; | 4612 m_pLastChild = pNode; |
4618 } | 4613 } |
4619 ASSERT(m_pLastChild); | 4614 ASSERT(m_pLastChild); |
4620 ASSERT(m_pLastChild->m_pNext == NULL); | 4615 ASSERT(m_pLastChild->m_pNext == NULL); |
4621 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); | 4616 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
4622 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4617 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4623 if (pNotify) { | 4618 if (pNotify) |
4624 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); | 4619 pNotify->OnChildAdded(this); |
4625 } | 4620 |
4626 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4621 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
4627 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4622 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
4628 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); | 4623 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); |
4629 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); | 4624 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); |
4630 } | 4625 } |
4631 return index; | 4626 return index; |
4632 } | 4627 } |
4633 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { | 4628 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { |
4634 if (!pNode || pNode->m_pParent || | 4629 if (!pNode || pNode->m_pParent || |
4635 (pBeforeNode && pBeforeNode->m_pParent != this)) { | 4630 (pBeforeNode && pBeforeNode->m_pParent != this)) { |
(...skipping 23 matching lines...) Expand all Loading... | |
4659 pNode->m_pNext = pPrev->m_pNext; | 4654 pNode->m_pNext = pPrev->m_pNext; |
4660 pPrev->m_pNext = pNode; | 4655 pPrev->m_pNext = pNode; |
4661 } | 4656 } |
4662 if (pNode->m_pNext == NULL) { | 4657 if (pNode->m_pNext == NULL) { |
4663 m_pLastChild = pNode; | 4658 m_pLastChild = pNode; |
4664 } | 4659 } |
4665 ASSERT(m_pLastChild); | 4660 ASSERT(m_pLastChild); |
4666 ASSERT(m_pLastChild->m_pNext == NULL); | 4661 ASSERT(m_pLastChild->m_pNext == NULL); |
4667 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); | 4662 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
4668 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4663 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4669 if (pNotify) { | 4664 if (pNotify) |
4670 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); | 4665 pNotify->OnChildAdded(this); |
4671 } | 4666 |
4672 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4667 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
4673 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4668 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
4674 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); | 4669 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); |
4675 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); | 4670 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); |
4676 } | 4671 } |
4677 return TRUE; | 4672 return TRUE; |
4678 } | 4673 } |
4679 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { | 4674 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { |
4680 if (!m_pParent) { | 4675 if (!m_pParent) { |
4681 return NULL; | 4676 return NULL; |
4682 } | 4677 } |
4683 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; | 4678 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; |
4684 pSibling = pSibling->m_pNext) { | 4679 pSibling = pSibling->m_pNext) { |
4685 if (pSibling->m_pNext == this) { | 4680 if (pSibling->m_pNext == this) { |
4686 return pSibling; | 4681 return pSibling; |
4687 } | 4682 } |
4688 } | 4683 } |
4689 return NULL; | 4684 return NULL; |
4690 } | 4685 } |
4691 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) { | 4686 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { |
4692 if (pNode == NULL || pNode->m_pParent != this) { | 4687 if (pNode == NULL || pNode->m_pParent != this) { |
4693 FXSYS_assert(FALSE); | 4688 FXSYS_assert(FALSE); |
4694 return FALSE; | 4689 return FALSE; |
4695 } | 4690 } |
4696 if (m_pChild == pNode) { | 4691 if (m_pChild == pNode) { |
4697 m_pChild = pNode->m_pNext; | 4692 m_pChild = pNode->m_pNext; |
4698 if (m_pLastChild == pNode) { | 4693 if (m_pLastChild == pNode) { |
4699 m_pLastChild = pNode->m_pNext; | 4694 m_pLastChild = pNode->m_pNext; |
4700 } | 4695 } |
4701 pNode->m_pNext = NULL; | 4696 pNode->m_pNext = NULL; |
4702 pNode->m_pParent = NULL; | 4697 pNode->m_pParent = NULL; |
4703 } else { | 4698 } else { |
4704 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); | 4699 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); |
4705 pPrev->m_pNext = pNode->m_pNext; | 4700 pPrev->m_pNext = pNode->m_pNext; |
4706 if (m_pLastChild == pNode) { | 4701 if (m_pLastChild == pNode) { |
4707 m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; | 4702 m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; |
4708 } | 4703 } |
4709 pNode->m_pNext = NULL; | 4704 pNode->m_pNext = NULL; |
4710 pNode->m_pParent = NULL; | 4705 pNode->m_pParent = NULL; |
4711 } | 4706 } |
4712 ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL); | 4707 ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL); |
4713 OnRemoved(this, pNode, bNotify); | 4708 OnRemoved(bNotify); |
4714 pNode->SetFlag(XFA_NODEFLAG_HasRemoved); | 4709 pNode->SetFlag(XFA_NODEFLAG_HasRemoved); |
4715 m_pDocument->AddPurgeNode(pNode); | 4710 m_pDocument->AddPurgeNode(pNode); |
4716 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4711 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
4717 if (pNode->IsAttributeInXML()) { | 4712 if (pNode->IsAttributeInXML()) { |
4718 FXSYS_assert(pNode->m_pXMLNode == m_pXMLNode && | 4713 FXSYS_assert(pNode->m_pXMLNode == m_pXMLNode && |
4719 m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 4714 m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
4720 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { | 4715 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { |
4721 CFDE_XMLElement* pXMLElement = | 4716 CFDE_XMLElement* pXMLElement = |
4722 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode); | 4717 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode); |
4723 CFX_WideStringC wsAttributeName = | 4718 CFX_WideStringC wsAttributeName = |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4844 return TRUE; | 4839 return TRUE; |
4845 } | 4840 } |
4846 switch (dwFlag) { | 4841 switch (dwFlag) { |
4847 case XFA_NODEFLAG_HasRemoved: | 4842 case XFA_NODEFLAG_HasRemoved: |
4848 return m_pParent && m_pParent->HasFlag(dwFlag); | 4843 return m_pParent && m_pParent->HasFlag(dwFlag); |
4849 default: | 4844 default: |
4850 break; | 4845 break; |
4851 } | 4846 } |
4852 return FALSE; | 4847 return FALSE; |
4853 } | 4848 } |
4854 void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { | 4849 |
4855 if (bOn) { | 4850 void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, bool bNotify) { |
Tom Sepez
2016/04/14 22:08:55
might be worth having a separate ClearFlag rather
Lei Zhang
2016/04/15 01:16:41
Done.
| |
4856 switch (dwFlag) { | 4851 if (!bOn) { |
4857 case XFA_NODEFLAG_Initialized: | 4852 m_uFlags &= ~dwFlag; |
4858 if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { | 4853 return; |
4859 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4854 } |
4860 if (pNotify) { | 4855 |
4861 pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready); | 4856 if (dwFlag == XFA_NODEFLAG_Initialized && bNotify && |
4862 } | 4857 !HasFlag(XFA_NODEFLAG_Initialized)) { |
4863 } | 4858 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4864 break; | 4859 if (pNotify) { |
4865 default: | 4860 pNotify->OnNodeReady(this); |
4866 break; | |
4867 } | 4861 } |
4868 m_uFlags |= dwFlag; | |
4869 } else { | |
4870 m_uFlags &= ~dwFlag; | |
4871 } | 4862 } |
4863 m_uFlags |= dwFlag; | |
4872 } | 4864 } |
4865 | |
4873 FX_BOOL CXFA_Node::IsAttributeInXML() { | 4866 FX_BOOL CXFA_Node::IsAttributeInXML() { |
4874 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; | 4867 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; |
4875 } | 4868 } |
4876 void CXFA_Node::OnRemoved(CXFA_Node* pParent, | 4869 |
4877 CXFA_Node* pRemoved, | 4870 void CXFA_Node::OnRemoved(bool bNotify) { |
4878 FX_BOOL bNotify) { | 4871 if (bNotify) { |
4879 if (bNotify && pParent) { | |
4880 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4872 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4881 if (pNotify) { | 4873 if (pNotify) { |
4882 pNotify->OnNodeEvent(pParent, XFA_NODEEVENT_ChildRemoved, pRemoved); | 4874 pNotify->OnChildRemoved(); |
4883 } | 4875 } |
4884 } | 4876 } |
4885 } | 4877 } |
4886 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, | 4878 |
4887 void* pNewValue, | 4879 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) { |
4888 FX_BOOL bNotify) { | |
4889 if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { | 4880 if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { |
4890 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4881 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4891 if (pNotify) { | 4882 if (pNotify) { |
4892 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanging, | 4883 pNotify->OnValueChanging(this, eAttr); |
4893 (void*)(uintptr_t)eAttr, pNewValue); | |
4894 } | 4884 } |
4895 } | 4885 } |
4896 } | 4886 } |
4887 | |
4897 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, | 4888 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, |
4898 void* pNewValue, | 4889 bool bNotify, |
4899 FX_BOOL bNotify, | |
4900 FX_BOOL bScriptModify) { | 4890 FX_BOOL bScriptModify) { |
4901 if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { | 4891 if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { |
4902 Script_Attribute_SendAttributeChangeMessage((void*)(uintptr_t)eAttr, | 4892 Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify); |
4903 pNewValue, bScriptModify); | |
4904 } | 4893 } |
4905 } | 4894 } |
4895 | |
4906 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, | 4896 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, |
4907 XFA_ELEMENT eElementType) { | 4897 XFA_ELEMENT eElementType) { |
4908 int32_t iRet = XFA_EVENTERROR_NotExist; | 4898 int32_t iRet = XFA_EVENTERROR_NotExist; |
4909 const XFA_ExecEventParaInfo* eventParaInfo = | 4899 const XFA_ExecEventParaInfo* eventParaInfo = |
4910 GetEventParaInfoByName(wsEventName); | 4900 GetEventParaInfoByName(wsEventName); |
4911 if (eventParaInfo) { | 4901 if (eventParaInfo) { |
4912 uint32_t validFlags = eventParaInfo->m_validFlags; | 4902 uint32_t validFlags = eventParaInfo->m_validFlags; |
4913 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4903 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
4914 if (!pNotify) { | 4904 if (!pNotify) { |
4915 return iRet; | 4905 return iRet; |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5410 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5400 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5411 } | 5401 } |
5412 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5402 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5413 return m_pAttachNode->RemoveChild(pNode); | 5403 return m_pAttachNode->RemoveChild(pNode); |
5414 } | 5404 } |
5415 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5405 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5416 return m_pAttachNode->GetChild( | 5406 return m_pAttachNode->GetChild( |
5417 iIndex, XFA_ELEMENT_UNKNOWN, | 5407 iIndex, XFA_ELEMENT_UNKNOWN, |
5418 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5408 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
5419 } | 5409 } |
OLD | NEW |