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