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, wsHref, wsValue); | 232 SetImageEdit(wsContentType.AsWideStringC(), wsHref.AsWideStringC(), |
| 233 wsValue.AsWideStringC()); |
233 } break; | 234 } break; |
234 case XFA_ELEMENT_ExclGroup: { | 235 case XFA_ELEMENT_ExclGroup: { |
235 CXFA_Node* pNextChild = m_pNode->GetNodeItem( | 236 CXFA_Node* pNextChild = m_pNode->GetNodeItem( |
236 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); | 237 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); |
237 while (pNextChild) { | 238 while (pNextChild) { |
238 CXFA_Node* pChild = pNextChild; | 239 CXFA_Node* pChild = pNextChild; |
239 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); | 240 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); |
240 if (!pAcc) { | 241 if (!pAcc) { |
241 continue; | 242 continue; |
242 } | 243 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 validate.GetScriptMessageText(wsScriptMsg); | 405 validate.GetScriptMessageText(wsScriptMsg); |
405 int32_t eScriptTest = validate.GetScriptTest(); | 406 int32_t eScriptTest = validate.GetScriptTest(); |
406 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { | 407 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { |
407 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 408 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
408 return; | 409 return; |
409 } | 410 } |
410 if (wsScriptMsg.IsEmpty()) { | 411 if (wsScriptMsg.IsEmpty()) { |
411 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); | 412 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); |
412 } | 413 } |
413 if (bVersionFlag) { | 414 if (bVersionFlag) { |
414 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, | 415 pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), |
| 416 wsTitle.AsWideStringC(), XFA_MBICON_Warning, |
415 XFA_MB_OK); | 417 XFA_MB_OK); |
416 return; | 418 return; |
417 } | 419 } |
418 if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, | 420 if (pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), |
| 421 wsTitle.AsWideStringC(), XFA_MBICON_Warning, |
419 XFA_MB_YesNo) == XFA_IDYes) { | 422 XFA_MB_YesNo) == XFA_IDYes) { |
420 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 423 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
421 } | 424 } |
422 } else { | 425 } else { |
423 if (wsScriptMsg.IsEmpty()) { | 426 if (wsScriptMsg.IsEmpty()) { |
424 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); | 427 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); |
425 } | 428 } |
426 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); | 429 pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(), |
| 430 wsTitle.AsWideStringC(), XFA_MBICON_Error, |
| 431 XFA_MB_OK); |
427 } | 432 } |
428 } | 433 } |
429 } | 434 } |
430 } | 435 } |
431 int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, | 436 int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, |
432 FX_BOOL bVersionFlag) { | 437 FX_BOOL bVersionFlag) { |
433 CFX_WideString wsRawValue = GetRawValue(); | 438 CFX_WideString wsRawValue = GetRawValue(); |
434 if (!wsRawValue.IsEmpty()) { | 439 if (!wsRawValue.IsEmpty()) { |
435 CFX_WideString wsPicture; | 440 CFX_WideString wsPicture; |
436 validate.GetPicture(wsPicture); | 441 validate.GetPicture(wsPicture); |
(...skipping 12 matching lines...) Expand all Loading... |
449 } | 454 } |
450 CFX_WideString wsFormatMsg; | 455 CFX_WideString wsFormatMsg; |
451 validate.GetFormatMessageText(wsFormatMsg); | 456 validate.GetFormatMessageText(wsFormatMsg); |
452 CFX_WideString wsTitle; | 457 CFX_WideString wsTitle; |
453 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); | 458 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); |
454 int32_t eFormatTest = validate.GetFormatTest(); | 459 int32_t eFormatTest = validate.GetFormatTest(); |
455 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { | 460 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { |
456 if (wsFormatMsg.IsEmpty()) { | 461 if (wsFormatMsg.IsEmpty()) { |
457 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); | 462 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); |
458 } | 463 } |
459 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); | 464 pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), |
| 465 wsTitle.AsWideStringC(), XFA_MBICON_Error, |
| 466 XFA_MB_OK); |
460 return XFA_EVENTERROR_Success; | 467 return XFA_EVENTERROR_Success; |
461 } | 468 } |
462 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 469 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
463 return XFA_EVENTERROR_NotExist; | 470 return XFA_EVENTERROR_NotExist; |
464 } | 471 } |
465 if (wsFormatMsg.IsEmpty()) { | 472 if (wsFormatMsg.IsEmpty()) { |
466 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); | 473 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); |
467 } | 474 } |
468 if (bVersionFlag) { | 475 if (bVersionFlag) { |
469 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, | 476 pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), |
| 477 wsTitle.AsWideStringC(), XFA_MBICON_Warning, |
470 XFA_MB_OK); | 478 XFA_MB_OK); |
471 return XFA_EVENTERROR_Success; | 479 return XFA_EVENTERROR_Success; |
472 } | 480 } |
473 if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, | 481 if (pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(), |
| 482 wsTitle.AsWideStringC(), XFA_MBICON_Warning, |
474 XFA_MB_YesNo) == XFA_IDYes) { | 483 XFA_MB_YesNo) == XFA_IDYes) { |
475 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 484 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
476 } | 485 } |
477 return XFA_EVENTERROR_Success; | 486 return XFA_EVENTERROR_Success; |
478 } | 487 } |
479 } | 488 } |
480 return XFA_EVENTERROR_NotExist; | 489 return XFA_EVENTERROR_NotExist; |
481 } | 490 } |
482 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, | 491 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, |
483 int32_t iFlags, | 492 int32_t iFlags, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 CFX_WideString wsTitle; | 528 CFX_WideString wsTitle; |
520 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); | 529 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); |
521 switch (eNullTest) { | 530 switch (eNullTest) { |
522 case XFA_ATTRIBUTEENUM_Error: { | 531 case XFA_ATTRIBUTEENUM_Error: { |
523 if (wsNullMsg.IsEmpty()) { | 532 if (wsNullMsg.IsEmpty()) { |
524 GetValidateCaptionName(wsCaptionName, bVersionFlag); | 533 GetValidateCaptionName(wsCaptionName, bVersionFlag); |
525 CFX_WideString wsError; | 534 CFX_WideString wsError; |
526 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); | 535 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); |
527 wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); | 536 wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); |
528 } | 537 } |
529 pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); | 538 pAppProvider->MsgBox(wsNullMsg.AsWideStringC(), wsTitle.AsWideStringC(), |
| 539 XFA_MBICON_Status, XFA_MB_OK); |
530 return XFA_EVENTERROR_Error; | 540 return XFA_EVENTERROR_Error; |
531 } | 541 } |
532 case XFA_ATTRIBUTEENUM_Warning: { | 542 case XFA_ATTRIBUTEENUM_Warning: { |
533 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 543 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
534 return TRUE; | 544 return TRUE; |
535 } | 545 } |
536 if (wsNullMsg.IsEmpty()) { | 546 if (wsNullMsg.IsEmpty()) { |
537 GetValidateCaptionName(wsCaptionName, bVersionFlag); | 547 GetValidateCaptionName(wsCaptionName, bVersionFlag); |
538 CFX_WideString wsWarning; | 548 CFX_WideString wsWarning; |
539 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); | 549 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); |
540 wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, | 550 wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, |
541 (const FX_WCHAR*)wsCaptionName); | 551 (const FX_WCHAR*)wsCaptionName); |
542 } | 552 } |
543 if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, | 553 if (pAppProvider->MsgBox(wsNullMsg.AsWideStringC(), |
| 554 wsTitle.AsWideStringC(), XFA_MBICON_Warning, |
544 XFA_MB_YesNo) == XFA_IDYes) { | 555 XFA_MB_YesNo) == XFA_IDYes) { |
545 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); | 556 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); |
546 } | 557 } |
547 return XFA_EVENTERROR_Error; | 558 return XFA_EVENTERROR_Error; |
548 } | 559 } |
549 case XFA_ATTRIBUTEENUM_Disabled: | 560 case XFA_ATTRIBUTEENUM_Disabled: |
550 default: | 561 default: |
551 break; | 562 break; |
552 } | 563 } |
553 return XFA_EVENTERROR_Success; | 564 return XFA_EVENTERROR_Success; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); | 675 CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); |
665 pContext->SetEventParam(*pEventParam); | 676 pContext->SetEventParam(*pEventParam); |
666 pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); | 677 pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); |
667 CXFA_NodeArray refNodes; | 678 CXFA_NodeArray refNodes; |
668 if (pEventParam->m_eType == XFA_EVENT_InitCalculate || | 679 if (pEventParam->m_eType == XFA_EVENT_InitCalculate || |
669 pEventParam->m_eType == XFA_EVENT_Calculate) { | 680 pEventParam->m_eType == XFA_EVENT_Calculate) { |
670 pContext->SetNodesOfRunScript(&refNodes); | 681 pContext->SetNodesOfRunScript(&refNodes); |
671 } | 682 } |
672 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); | 683 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); |
673 ++m_nRecursionDepth; | 684 ++m_nRecursionDepth; |
674 FX_BOOL bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, | 685 FX_BOOL bRet = |
675 wsExpression, hRetValue, m_pNode); | 686 pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, |
| 687 wsExpression.AsWideStringC(), hRetValue, m_pNode); |
676 --m_nRecursionDepth; | 688 --m_nRecursionDepth; |
677 int32_t iRet = XFA_EVENTERROR_Error; | 689 int32_t iRet = XFA_EVENTERROR_Error; |
678 if (bRet) { | 690 if (bRet) { |
679 iRet = XFA_EVENTERROR_Success; | 691 iRet = XFA_EVENTERROR_Success; |
680 if (pEventParam->m_eType == XFA_EVENT_Calculate || | 692 if (pEventParam->m_eType == XFA_EVENT_Calculate || |
681 pEventParam->m_eType == XFA_EVENT_InitCalculate) { | 693 pEventParam->m_eType == XFA_EVENT_InitCalculate) { |
682 if (!FXJSE_Value_IsUndefined(hRetValue)) { | 694 if (!FXJSE_Value_IsUndefined(hRetValue)) { |
683 if (!FXJSE_Value_IsNull(hRetValue)) { | 695 if (!FXJSE_Value_IsNull(hRetValue)) { |
684 CFX_ByteString bsString; | 696 CFX_ByteString bsString; |
685 FXJSE_Value_ToUTF8String(hRetValue, bsString); | 697 FXJSE_Value_ToUTF8String(hRetValue, bsString); |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { | 1705 if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { |
1694 return FALSE; | 1706 return FALSE; |
1695 } | 1707 } |
1696 if (bURI) { | 1708 if (bURI) { |
1697 CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); | 1709 CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); |
1698 CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); | 1710 CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); |
1699 CXFA_Document* pDocument = pWidgetNode->GetDocument(); | 1711 CXFA_Document* pDocument = pWidgetNode->GetDocument(); |
1700 CXFA_Node* pIDNode = NULL; | 1712 CXFA_Node* pIDNode = NULL; |
1701 CXFA_WidgetAcc* pEmbAcc = NULL; | 1713 CXFA_WidgetAcc* pEmbAcc = NULL; |
1702 if (pParent) { | 1714 if (pParent) { |
1703 pIDNode = pDocument->GetNodeByID(pParent, wsAttr); | 1715 pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsWideStringC()); |
1704 } | 1716 } |
1705 if (!pIDNode) { | 1717 if (!pIDNode) { |
1706 pIDNode = pDocument->GetNodeByID( | 1718 pIDNode = pDocument->GetNodeByID( |
1707 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), wsAttr); | 1719 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), |
| 1720 wsAttr.AsWideStringC()); |
1708 } | 1721 } |
1709 if (pIDNode) { | 1722 if (pIDNode) { |
1710 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); | 1723 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); |
1711 } | 1724 } |
1712 if (pEmbAcc) { | 1725 if (pEmbAcc) { |
1713 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 1726 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
1714 return TRUE; | 1727 return TRUE; |
1715 } | 1728 } |
1716 } | 1729 } |
1717 return FALSE; | 1730 return FALSE; |
1718 } | 1731 } |
OLD | NEW |