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/app/xfa_ffwidgetacc.h" | 7 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 switch (eUIType) { | 222 switch (eUIType) { |
223 case XFA_ELEMENT_ImageEdit: { | 223 case XFA_ELEMENT_ImageEdit: { |
224 CXFA_Value imageValue = GetDefaultValue(); | 224 CXFA_Value imageValue = GetDefaultValue(); |
225 CXFA_Image image = imageValue.GetImage(); | 225 CXFA_Image image = imageValue.GetImage(); |
226 CFX_WideString wsContentType, wsHref; | 226 CFX_WideString wsContentType, wsHref; |
227 if (image) { | 227 if (image) { |
228 image.GetContent(wsValue); | 228 image.GetContent(wsValue); |
229 image.GetContentType(wsContentType); | 229 image.GetContentType(wsContentType); |
230 image.GetHref(wsHref); | 230 image.GetHref(wsHref); |
231 } | 231 } |
232 SetImageEdit(wsContentType.AsWideStringC(), wsHref.AsWideStringC(), | 232 SetImageEdit(wsContentType.AsStringC(), wsHref.AsStringC(), |
233 wsValue.AsWideStringC()); | 233 wsValue.AsStringC()); |
234 } break; | 234 } break; |
235 case XFA_ELEMENT_ExclGroup: { | 235 case XFA_ELEMENT_ExclGroup: { |
236 CXFA_Node* pNextChild = m_pNode->GetNodeItem( | 236 CXFA_Node* pNextChild = m_pNode->GetNodeItem( |
237 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); | 237 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); |
238 while (pNextChild) { | 238 while (pNextChild) { |
239 CXFA_Node* pChild = pNextChild; | 239 CXFA_Node* pChild = pNextChild; |
240 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); | 240 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); |
241 if (!pAcc) { | 241 if (!pAcc) { |
242 continue; | 242 continue; |
243 } | 243 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 validate.GetScriptMessageText(wsScriptMsg); | 405 validate.GetScriptMessageText(wsScriptMsg); |
406 int32_t eScriptTest = validate.GetScriptTest(); | 406 int32_t eScriptTest = validate.GetScriptTest(); |
407 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { | 407 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { |
408 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 408 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
409 return; | 409 return; |
410 } | 410 } |
411 if (wsScriptMsg.IsEmpty()) { | 411 if (wsScriptMsg.IsEmpty()) { |
412 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); | 412 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); |
413 } | 413 } |
414 if (bVersionFlag) { | 414 if (bVersionFlag) { |
415 pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), | 415 pAppProvider->MsgBox(wsScriptMsg.AsStringC(), wsTitle.AsStringC(), |
416 wsTitle.AsWideStringC(), XFA_MBICON_Warning, | 416 XFA_MBICON_Warning, XFA_MB_OK); |
417 XFA_MB_OK); | |
418 return; | 417 return; |
419 } | 418 } |
420 if (pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), | 419 if (pAppProvider->MsgBox(wsScriptMsg.AsStringC(), wsTitle.AsStringC(), |
421 wsTitle.AsWideStringC(), XFA_MBICON_Warning, | 420 XFA_MBICON_Warning, |
422 XFA_MB_YesNo) == XFA_IDYes) { | 421 XFA_MB_YesNo) == XFA_IDYes) { |
423 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 422 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
424 } | 423 } |
425 } else { | 424 } else { |
426 if (wsScriptMsg.IsEmpty()) { | 425 if (wsScriptMsg.IsEmpty()) { |
427 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); | 426 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); |
428 } | 427 } |
429 pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), | 428 pAppProvider->MsgBox(wsScriptMsg.AsStringC(), wsTitle.AsStringC(), |
430 wsTitle.AsWideStringC(), XFA_MBICON_Error, | 429 XFA_MBICON_Error, XFA_MB_OK); |
431 XFA_MB_OK); | |
432 } | 430 } |
433 } | 431 } |
434 } | 432 } |
435 } | 433 } |
436 int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, | 434 int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, |
437 FX_BOOL bVersionFlag) { | 435 FX_BOOL bVersionFlag) { |
438 CFX_WideString wsRawValue = GetRawValue(); | 436 CFX_WideString wsRawValue = GetRawValue(); |
439 if (!wsRawValue.IsEmpty()) { | 437 if (!wsRawValue.IsEmpty()) { |
440 CFX_WideString wsPicture; | 438 CFX_WideString wsPicture; |
441 validate.GetPicture(wsPicture); | 439 validate.GetPicture(wsPicture); |
(...skipping 12 matching lines...) Expand all Loading... |
454 } | 452 } |
455 CFX_WideString wsFormatMsg; | 453 CFX_WideString wsFormatMsg; |
456 validate.GetFormatMessageText(wsFormatMsg); | 454 validate.GetFormatMessageText(wsFormatMsg); |
457 CFX_WideString wsTitle; | 455 CFX_WideString wsTitle; |
458 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); | 456 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); |
459 int32_t eFormatTest = validate.GetFormatTest(); | 457 int32_t eFormatTest = validate.GetFormatTest(); |
460 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { | 458 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { |
461 if (wsFormatMsg.IsEmpty()) { | 459 if (wsFormatMsg.IsEmpty()) { |
462 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); | 460 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); |
463 } | 461 } |
464 pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), | 462 pAppProvider->MsgBox(wsFormatMsg.AsStringC(), wsTitle.AsStringC(), |
465 wsTitle.AsWideStringC(), XFA_MBICON_Error, | 463 XFA_MBICON_Error, XFA_MB_OK); |
466 XFA_MB_OK); | |
467 return XFA_EVENTERROR_Success; | 464 return XFA_EVENTERROR_Success; |
468 } | 465 } |
469 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 466 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
470 return XFA_EVENTERROR_NotExist; | 467 return XFA_EVENTERROR_NotExist; |
471 } | 468 } |
472 if (wsFormatMsg.IsEmpty()) { | 469 if (wsFormatMsg.IsEmpty()) { |
473 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); | 470 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); |
474 } | 471 } |
475 if (bVersionFlag) { | 472 if (bVersionFlag) { |
476 pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), | 473 pAppProvider->MsgBox(wsFormatMsg.AsStringC(), wsTitle.AsStringC(), |
477 wsTitle.AsWideStringC(), XFA_MBICON_Warning, | 474 XFA_MBICON_Warning, XFA_MB_OK); |
478 XFA_MB_OK); | |
479 return XFA_EVENTERROR_Success; | 475 return XFA_EVENTERROR_Success; |
480 } | 476 } |
481 if (pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), | 477 if (pAppProvider->MsgBox(wsFormatMsg.AsStringC(), wsTitle.AsStringC(), |
482 wsTitle.AsWideStringC(), XFA_MBICON_Warning, | 478 XFA_MBICON_Warning, XFA_MB_YesNo) == XFA_IDYes) { |
483 XFA_MB_YesNo) == XFA_IDYes) { | |
484 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 479 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
485 } | 480 } |
486 return XFA_EVENTERROR_Success; | 481 return XFA_EVENTERROR_Success; |
487 } | 482 } |
488 } | 483 } |
489 return XFA_EVENTERROR_NotExist; | 484 return XFA_EVENTERROR_NotExist; |
490 } | 485 } |
491 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, | 486 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, |
492 int32_t iFlags, | 487 int32_t iFlags, |
493 FX_BOOL bVersionFlag) { | 488 FX_BOOL bVersionFlag) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 CFX_WideString wsTitle; | 523 CFX_WideString wsTitle; |
529 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); | 524 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); |
530 switch (eNullTest) { | 525 switch (eNullTest) { |
531 case XFA_ATTRIBUTEENUM_Error: { | 526 case XFA_ATTRIBUTEENUM_Error: { |
532 if (wsNullMsg.IsEmpty()) { | 527 if (wsNullMsg.IsEmpty()) { |
533 GetValidateCaptionName(wsCaptionName, bVersionFlag); | 528 GetValidateCaptionName(wsCaptionName, bVersionFlag); |
534 CFX_WideString wsError; | 529 CFX_WideString wsError; |
535 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); | 530 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); |
536 wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); | 531 wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); |
537 } | 532 } |
538 pAppProvider->MsgBox(wsNullMsg.AsWideStringC(), wsTitle.AsWideStringC(), | 533 pAppProvider->MsgBox(wsNullMsg.AsStringC(), wsTitle.AsStringC(), |
539 XFA_MBICON_Status, XFA_MB_OK); | 534 XFA_MBICON_Status, XFA_MB_OK); |
540 return XFA_EVENTERROR_Error; | 535 return XFA_EVENTERROR_Error; |
541 } | 536 } |
542 case XFA_ATTRIBUTEENUM_Warning: { | 537 case XFA_ATTRIBUTEENUM_Warning: { |
543 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 538 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
544 return TRUE; | 539 return TRUE; |
545 } | 540 } |
546 if (wsNullMsg.IsEmpty()) { | 541 if (wsNullMsg.IsEmpty()) { |
547 GetValidateCaptionName(wsCaptionName, bVersionFlag); | 542 GetValidateCaptionName(wsCaptionName, bVersionFlag); |
548 CFX_WideString wsWarning; | 543 CFX_WideString wsWarning; |
549 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); | 544 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); |
550 wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, | 545 wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, |
551 (const FX_WCHAR*)wsCaptionName); | 546 (const FX_WCHAR*)wsCaptionName); |
552 } | 547 } |
553 if (pAppProvider->MsgBox(wsNullMsg.AsWideStringC(), | 548 if (pAppProvider->MsgBox(wsNullMsg.AsStringC(), wsTitle.AsStringC(), |
554 wsTitle.AsWideStringC(), XFA_MBICON_Warning, | 549 XFA_MBICON_Warning, XFA_MB_YesNo) == XFA_IDYes) { |
555 XFA_MB_YesNo) == XFA_IDYes) { | |
556 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 550 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
557 } | 551 } |
558 return XFA_EVENTERROR_Error; | 552 return XFA_EVENTERROR_Error; |
559 } | 553 } |
560 case XFA_ATTRIBUTEENUM_Disabled: | 554 case XFA_ATTRIBUTEENUM_Disabled: |
561 default: | 555 default: |
562 break; | 556 break; |
563 } | 557 } |
564 return XFA_EVENTERROR_Success; | 558 return XFA_EVENTERROR_Success; |
565 } | 559 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); | 671 pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); |
678 CXFA_NodeArray refNodes; | 672 CXFA_NodeArray refNodes; |
679 if (pEventParam->m_eType == XFA_EVENT_InitCalculate || | 673 if (pEventParam->m_eType == XFA_EVENT_InitCalculate || |
680 pEventParam->m_eType == XFA_EVENT_Calculate) { | 674 pEventParam->m_eType == XFA_EVENT_Calculate) { |
681 pContext->SetNodesOfRunScript(&refNodes); | 675 pContext->SetNodesOfRunScript(&refNodes); |
682 } | 676 } |
683 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); | 677 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); |
684 ++m_nRecursionDepth; | 678 ++m_nRecursionDepth; |
685 FX_BOOL bRet = | 679 FX_BOOL bRet = |
686 pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, | 680 pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, |
687 wsExpression.AsWideStringC(), hRetValue, m_pNode); | 681 wsExpression.AsStringC(), hRetValue, m_pNode); |
688 --m_nRecursionDepth; | 682 --m_nRecursionDepth; |
689 int32_t iRet = XFA_EVENTERROR_Error; | 683 int32_t iRet = XFA_EVENTERROR_Error; |
690 if (bRet) { | 684 if (bRet) { |
691 iRet = XFA_EVENTERROR_Success; | 685 iRet = XFA_EVENTERROR_Success; |
692 if (pEventParam->m_eType == XFA_EVENT_Calculate || | 686 if (pEventParam->m_eType == XFA_EVENT_Calculate || |
693 pEventParam->m_eType == XFA_EVENT_InitCalculate) { | 687 pEventParam->m_eType == XFA_EVENT_InitCalculate) { |
694 if (!FXJSE_Value_IsUndefined(hRetValue)) { | 688 if (!FXJSE_Value_IsUndefined(hRetValue)) { |
695 if (!FXJSE_Value_IsNull(hRetValue)) { | 689 if (!FXJSE_Value_IsNull(hRetValue)) { |
696 CFX_ByteString bsString; | 690 CFX_ByteString bsString; |
697 FXJSE_Value_ToUTF8String(hRetValue, bsString); | 691 FXJSE_Value_ToUTF8String(hRetValue, bsString); |
698 pEventParam->m_wsResult = | 692 pEventParam->m_wsResult = |
699 CFX_WideString::FromUTF8(bsString.AsByteStringC()); | 693 CFX_WideString::FromUTF8(bsString.AsStringC()); |
700 } | 694 } |
701 iRet = XFA_EVENTERROR_Success; | 695 iRet = XFA_EVENTERROR_Success; |
702 } else { | 696 } else { |
703 iRet = XFA_EVENTERROR_Error; | 697 iRet = XFA_EVENTERROR_Error; |
704 } | 698 } |
705 if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { | 699 if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { |
706 if ((iRet == XFA_EVENTERROR_Success) && | 700 if ((iRet == XFA_EVENTERROR_Success) && |
707 (GetRawValue() != pEventParam->m_wsResult)) { | 701 (GetRawValue() != pEventParam->m_wsResult)) { |
708 SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); | 702 SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); |
709 m_pDocView->AddValidateWidget(this); | 703 m_pDocView->AddValidateWidget(this); |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { | 1699 if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { |
1706 return FALSE; | 1700 return FALSE; |
1707 } | 1701 } |
1708 if (bURI) { | 1702 if (bURI) { |
1709 CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); | 1703 CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); |
1710 CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); | 1704 CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); |
1711 CXFA_Document* pDocument = pWidgetNode->GetDocument(); | 1705 CXFA_Document* pDocument = pWidgetNode->GetDocument(); |
1712 CXFA_Node* pIDNode = NULL; | 1706 CXFA_Node* pIDNode = NULL; |
1713 CXFA_WidgetAcc* pEmbAcc = NULL; | 1707 CXFA_WidgetAcc* pEmbAcc = NULL; |
1714 if (pParent) { | 1708 if (pParent) { |
1715 pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsWideStringC()); | 1709 pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsStringC()); |
1716 } | 1710 } |
1717 if (!pIDNode) { | 1711 if (!pIDNode) { |
1718 pIDNode = pDocument->GetNodeByID( | 1712 pIDNode = pDocument->GetNodeByID( |
1719 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), | 1713 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), |
1720 wsAttr.AsWideStringC()); | 1714 wsAttr.AsStringC()); |
1721 } | 1715 } |
1722 if (pIDNode) { | 1716 if (pIDNode) { |
1723 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); | 1717 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); |
1724 } | 1718 } |
1725 if (pEmbAcc) { | 1719 if (pEmbAcc) { |
1726 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 1720 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
1727 return TRUE; | 1721 return TRUE; |
1728 } | 1722 } |
1729 } | 1723 } |
1730 return FALSE; | 1724 return FALSE; |
1731 } | 1725 } |
OLD | NEW |