| 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 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 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 FX_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); |
| 3918 return TRUE; | 3908 return TRUE; |
| 3919 } | 3909 } |
| 3920 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, | 3910 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, |
| 3921 CXFA_Measurement& mValue, | 3911 CXFA_Measurement& mValue, |
| 3922 FX_BOOL bUseDefault) const { | 3912 FX_BOOL bUseDefault) const { |
| 3923 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3913 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 3924 void* pValue; | 3914 void* pValue; |
| 3925 int32_t iBytes; | 3915 int32_t iBytes; |
| 3926 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { | 3916 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { |
| 3927 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); | 3917 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3939 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { | 3929 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { |
| 3940 CXFA_Measurement mValue; | 3930 CXFA_Measurement mValue; |
| 3941 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); | 3931 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); |
| 3942 } | 3932 } |
| 3943 | 3933 |
| 3944 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, | 3934 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, |
| 3945 const CFX_WideString& wsValue, | 3935 const CFX_WideString& wsValue, |
| 3946 FX_BOOL bNotify, | 3936 FX_BOOL bNotify, |
| 3947 FX_BOOL bScriptModify) { | 3937 FX_BOOL bScriptModify) { |
| 3948 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3938 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 3949 OnChanging(eAttr, (void*)wsValue.c_str(), bNotify); | 3939 OnChanging(eAttr, bNotify); |
| 3950 if (eAttr == XFA_ATTRIBUTE_Value) { | 3940 if (eAttr == XFA_ATTRIBUTE_Value) { |
| 3951 CFX_WideString* pClone = new CFX_WideString(wsValue); | 3941 CFX_WideString* pClone = new CFX_WideString(wsValue); |
| 3952 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 3942 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
| 3953 } else { | 3943 } else { |
| 3954 SetMapModuleString(pKey, wsValue.AsStringC()); | 3944 SetMapModuleString(pKey, wsValue.AsStringC()); |
| 3955 if (eAttr == XFA_ATTRIBUTE_Name) | 3945 if (eAttr == XFA_ATTRIBUTE_Name) |
| 3956 UpdateNameHash(); | 3946 UpdateNameHash(); |
| 3957 } | 3947 } |
| 3958 OnChanged(eAttr, (void*)wsValue.c_str(), bNotify, bScriptModify); | 3948 OnChanged(eAttr, bNotify, bScriptModify); |
| 3959 if (IsNeedSavingXMLNode() && eAttr != XFA_ATTRIBUTE_QualifiedName && | 3949 if (IsNeedSavingXMLNode() && eAttr != XFA_ATTRIBUTE_QualifiedName && |
| 3960 eAttr != XFA_ATTRIBUTE_BindingNode) { | 3950 eAttr != XFA_ATTRIBUTE_BindingNode) { |
| 3961 if (eAttr == XFA_ATTRIBUTE_Name && | 3951 if (eAttr == XFA_ATTRIBUTE_Name && |
| 3962 (m_eNodeClass == XFA_ELEMENT_DataValue || | 3952 (m_eNodeClass == XFA_ELEMENT_DataValue || |
| 3963 m_eNodeClass == XFA_ELEMENT_DataGroup)) { | 3953 m_eNodeClass == XFA_ELEMENT_DataGroup)) { |
| 3964 return TRUE; | 3954 return TRUE; |
| 3965 } | 3955 } |
| 3966 if (eAttr == XFA_ATTRIBUTE_Value) { | 3956 if (eAttr == XFA_ATTRIBUTE_Value) { |
| 3967 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); | 3957 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
| 3968 switch (eXMLType) { | 3958 switch (eXMLType) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4008 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); | 3998 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); |
| 4009 } | 3999 } |
| 4010 } | 4000 } |
| 4011 return TRUE; | 4001 return TRUE; |
| 4012 } | 4002 } |
| 4013 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, | 4003 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, |
| 4014 const CFX_WideString& wsXMLValue, | 4004 const CFX_WideString& wsXMLValue, |
| 4015 FX_BOOL bNotify, | 4005 FX_BOOL bNotify, |
| 4016 FX_BOOL bScriptModify) { | 4006 FX_BOOL bScriptModify) { |
| 4017 void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); | 4007 void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); |
| 4018 OnChanging(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify); | 4008 OnChanging(XFA_ATTRIBUTE_Value, bNotify); |
| 4019 CFX_WideString* pClone = new CFX_WideString(wsValue); | 4009 CFX_WideString* pClone = new CFX_WideString(wsValue); |
| 4020 SetUserData(pKey, pClone, &deleteWideStringCallBack); | 4010 SetUserData(pKey, pClone, &deleteWideStringCallBack); |
| 4021 OnChanged(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify, | 4011 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); |
| 4022 bScriptModify); | |
| 4023 if (IsNeedSavingXMLNode()) { | 4012 if (IsNeedSavingXMLNode()) { |
| 4024 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); | 4013 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
| 4025 switch (eXMLType) { | 4014 switch (eXMLType) { |
| 4026 case FDE_XMLNODE_Element: | 4015 case FDE_XMLNODE_Element: |
| 4027 if (IsAttributeInXML()) { | 4016 if (IsAttributeInXML()) { |
| 4028 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4017 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
| 4029 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); | 4018 ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); |
| 4030 } else { | 4019 } else { |
| 4031 FX_BOOL bDeleteChildren = TRUE; | 4020 FX_BOOL bDeleteChildren = TRUE; |
| 4032 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 4021 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4121 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { | 4110 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { |
| 4122 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4111 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4123 pData = GetUserData(pKey); | 4112 pData = GetUserData(pKey); |
| 4124 return pData != NULL; | 4113 return pData != NULL; |
| 4125 } | 4114 } |
| 4126 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, | 4115 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, |
| 4127 XFA_ATTRIBUTETYPE eType, | 4116 XFA_ATTRIBUTETYPE eType, |
| 4128 void* pValue, | 4117 void* pValue, |
| 4129 FX_BOOL bNotify) { | 4118 FX_BOOL bNotify) { |
| 4130 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4119 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4131 OnChanging(eAttr, pValue, bNotify); | 4120 OnChanging(eAttr, bNotify); |
| 4132 SetMapModuleValue(pKey, pValue); | 4121 SetMapModuleValue(pKey, pValue); |
| 4133 OnChanged(eAttr, pValue, bNotify); | 4122 OnChanged(eAttr, bNotify); |
| 4134 if (IsNeedSavingXMLNode()) { | 4123 if (IsNeedSavingXMLNode()) { |
| 4135 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 4124 FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
| 4136 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); | 4125 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); |
| 4137 if (pInfo) { | 4126 if (pInfo) { |
| 4138 switch (eType) { | 4127 switch (eType) { |
| 4139 case XFA_ATTRIBUTETYPE_Enum: | 4128 case XFA_ATTRIBUTETYPE_Enum: |
| 4140 static_cast<CFDE_XMLElement*>(m_pXMLNode) | 4129 static_cast<CFDE_XMLElement*>(m_pXMLNode) |
| 4141 ->SetString( | 4130 ->SetString( |
| 4142 pInfo->pName, | 4131 pInfo->pName, |
| 4143 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) | 4132 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4613 pPrev->m_pNext = pNode; | 4602 pPrev->m_pNext = pNode; |
| 4614 index = iCount; | 4603 index = iCount; |
| 4615 } | 4604 } |
| 4616 if (pNode->m_pNext == NULL) { | 4605 if (pNode->m_pNext == NULL) { |
| 4617 m_pLastChild = pNode; | 4606 m_pLastChild = pNode; |
| 4618 } | 4607 } |
| 4619 ASSERT(m_pLastChild); | 4608 ASSERT(m_pLastChild); |
| 4620 ASSERT(m_pLastChild->m_pNext == NULL); | 4609 ASSERT(m_pLastChild->m_pNext == NULL); |
| 4621 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); | 4610 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
| 4622 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4611 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 4623 if (pNotify) { | 4612 if (pNotify) |
| 4624 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); | 4613 pNotify->OnChildAdded(this); |
| 4625 } | 4614 |
| 4626 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4615 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| 4627 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4616 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
| 4628 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); | 4617 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); |
| 4629 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); | 4618 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); |
| 4630 } | 4619 } |
| 4631 return index; | 4620 return index; |
| 4632 } | 4621 } |
| 4633 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { | 4622 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { |
| 4634 if (!pNode || pNode->m_pParent || | 4623 if (!pNode || pNode->m_pParent || |
| 4635 (pBeforeNode && pBeforeNode->m_pParent != this)) { | 4624 (pBeforeNode && pBeforeNode->m_pParent != this)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4659 pNode->m_pNext = pPrev->m_pNext; | 4648 pNode->m_pNext = pPrev->m_pNext; |
| 4660 pPrev->m_pNext = pNode; | 4649 pPrev->m_pNext = pNode; |
| 4661 } | 4650 } |
| 4662 if (pNode->m_pNext == NULL) { | 4651 if (pNode->m_pNext == NULL) { |
| 4663 m_pLastChild = pNode; | 4652 m_pLastChild = pNode; |
| 4664 } | 4653 } |
| 4665 ASSERT(m_pLastChild); | 4654 ASSERT(m_pLastChild); |
| 4666 ASSERT(m_pLastChild->m_pNext == NULL); | 4655 ASSERT(m_pLastChild->m_pNext == NULL); |
| 4667 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); | 4656 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
| 4668 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4657 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 4669 if (pNotify) { | 4658 if (pNotify) |
| 4670 pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); | 4659 pNotify->OnChildAdded(this); |
| 4671 } | 4660 |
| 4672 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4661 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| 4673 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4662 FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
| 4674 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); | 4663 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); |
| 4675 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); | 4664 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); |
| 4676 } | 4665 } |
| 4677 return TRUE; | 4666 return TRUE; |
| 4678 } | 4667 } |
| 4679 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { | 4668 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { |
| 4680 if (!m_pParent) { | 4669 if (!m_pParent) { |
| 4681 return NULL; | 4670 return NULL; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4851 } | 4840 } |
| 4852 return FALSE; | 4841 return FALSE; |
| 4853 } | 4842 } |
| 4854 void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { | 4843 void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { |
| 4855 if (bOn) { | 4844 if (bOn) { |
| 4856 switch (dwFlag) { | 4845 switch (dwFlag) { |
| 4857 case XFA_NODEFLAG_Initialized: | 4846 case XFA_NODEFLAG_Initialized: |
| 4858 if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { | 4847 if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { |
| 4859 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4848 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 4860 if (pNotify) { | 4849 if (pNotify) { |
| 4861 pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready); | 4850 pNotify->OnNodeReady(this); |
| 4862 } | 4851 } |
| 4863 } | 4852 } |
| 4864 break; | 4853 break; |
| 4865 default: | 4854 default: |
| 4866 break; | 4855 break; |
| 4867 } | 4856 } |
| 4868 m_uFlags |= dwFlag; | 4857 m_uFlags |= dwFlag; |
| 4869 } else { | 4858 } else { |
| 4870 m_uFlags &= ~dwFlag; | 4859 m_uFlags &= ~dwFlag; |
| 4871 } | 4860 } |
| 4872 } | 4861 } |
| 4873 FX_BOOL CXFA_Node::IsAttributeInXML() { | 4862 FX_BOOL CXFA_Node::IsAttributeInXML() { |
| 4874 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; | 4863 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; |
| 4875 } | 4864 } |
| 4865 |
| 4876 void CXFA_Node::OnRemoved(CXFA_Node* pParent, | 4866 void CXFA_Node::OnRemoved(CXFA_Node* pParent, |
| 4877 CXFA_Node* pRemoved, | 4867 CXFA_Node* pRemoved, |
| 4878 FX_BOOL bNotify) { | 4868 FX_BOOL bNotify) { |
| 4879 if (bNotify && pParent) { | 4869 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, FX_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, | |
| 4899 FX_BOOL bNotify, | 4887 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 } |
| 4906 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, | 4893 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, |
| 4907 XFA_ELEMENT eElementType) { | 4894 XFA_ELEMENT eElementType) { |
| 4908 int32_t iRet = XFA_EVENTERROR_NotExist; | 4895 int32_t iRet = XFA_EVENTERROR_NotExist; |
| 4909 const XFA_ExecEventParaInfo* eventParaInfo = | 4896 const XFA_ExecEventParaInfo* eventParaInfo = |
| 4910 GetEventParaInfoByName(wsEventName); | 4897 GetEventParaInfoByName(wsEventName); |
| 4911 if (eventParaInfo) { | 4898 if (eventParaInfo) { |
| 4912 uint32_t validFlags = eventParaInfo->m_validFlags; | 4899 uint32_t validFlags = eventParaInfo->m_validFlags; |
| 4913 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4900 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5410 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5397 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
| 5411 } | 5398 } |
| 5412 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5399 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
| 5413 return m_pAttachNode->RemoveChild(pNode); | 5400 return m_pAttachNode->RemoveChild(pNode); |
| 5414 } | 5401 } |
| 5415 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5402 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
| 5416 return m_pAttachNode->GetChild( | 5403 return m_pAttachNode->GetChild( |
| 5417 iIndex, XFA_ELEMENT_UNKNOWN, | 5404 iIndex, XFA_ELEMENT_UNKNOWN, |
| 5418 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5405 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
| 5419 } | 5406 } |
| OLD | NEW |