Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: xfa/fxfa/app/xfa_ffwidgetacc.cpp

Issue 2083453003: Split the XFA_OBJECTTYPE enum into two parts. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix == nullptr Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_ffwidgethandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <memory> 10 #include <memory>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 CFX_WideString wsContentType, wsHref; 207 CFX_WideString wsContentType, wsHref;
208 if (image) { 208 if (image) {
209 image.GetContent(wsValue); 209 image.GetContent(wsValue);
210 image.GetContentType(wsContentType); 210 image.GetContentType(wsContentType);
211 image.GetHref(wsHref); 211 image.GetHref(wsHref);
212 } 212 }
213 SetImageEdit(wsContentType, wsHref, wsValue); 213 SetImageEdit(wsContentType, wsHref, wsValue);
214 } break; 214 } break;
215 case XFA_ELEMENT_ExclGroup: { 215 case XFA_ELEMENT_ExclGroup: {
216 CXFA_Node* pNextChild = m_pNode->GetNodeItem( 216 CXFA_Node* pNextChild = m_pNode->GetNodeItem(
217 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); 217 XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
218 while (pNextChild) { 218 while (pNextChild) {
219 CXFA_Node* pChild = pNextChild; 219 CXFA_Node* pChild = pNextChild;
220 CXFA_WidgetAcc* pAcc = 220 CXFA_WidgetAcc* pAcc =
221 static_cast<CXFA_WidgetAcc*>(pChild->GetWidgetData()); 221 static_cast<CXFA_WidgetAcc*>(pChild->GetWidgetData());
222 if (!pAcc) { 222 if (!pAcc) {
223 continue; 223 continue;
224 } 224 }
225 CXFA_Value defValue(NULL); 225 CXFA_Value defValue(NULL);
226 if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) { 226 if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) {
227 defValue.GetChildValueContent(wsValue); 227 defValue.GetChildValueContent(wsValue);
228 SetValue(wsValue, XFA_VALUEPICTURE_Raw); 228 SetValue(wsValue, XFA_VALUEPICTURE_Raw);
229 pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); 229 pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw);
230 } else { 230 } else {
231 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); 231 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items);
232 if (!pItems) { 232 if (!pItems) {
233 continue; 233 continue;
234 } 234 }
235 CFX_WideString itemText; 235 CFX_WideString itemText;
236 if (pItems->CountChildren(XFA_ELEMENT_UNKNOWN) > 1) { 236 if (pItems->CountChildren(XFA_ELEMENT_UNKNOWN) > 1) {
237 itemText = pItems->GetChild(1, XFA_ELEMENT_UNKNOWN)->GetContent(); 237 itemText = pItems->GetChild(1, XFA_ELEMENT_UNKNOWN)->GetContent();
238 } 238 }
239 pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw); 239 pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw);
240 } 240 }
241 pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling, 241 pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling,
242 XFA_OBJECTTYPE_ContainerNode); 242 XFA_ObjectType::ContainerNode);
243 } 243 }
244 } break; 244 } break;
245 case XFA_ELEMENT_ChoiceList: 245 case XFA_ELEMENT_ChoiceList:
246 ClearAllSelections(); 246 ClearAllSelections();
247 default: 247 default:
248 if (CXFA_Value defValue = GetDefaultValue()) { 248 if (CXFA_Value defValue = GetDefaultValue()) {
249 defValue.GetChildValueContent(wsValue); 249 defValue.GetChildValueContent(wsValue);
250 } 250 }
251 SetValue(wsValue, XFA_VALUEPICTURE_Raw); 251 SetValue(wsValue, XFA_VALUEPICTURE_Raw);
252 break; 252 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 CXFA_Submit submit = event.GetSubmit(); 336 CXFA_Submit submit = event.GetSubmit();
337 return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); 337 return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit);
338 } 338 }
339 default: 339 default:
340 break; 340 break;
341 } 341 }
342 return XFA_EVENTERROR_NotExist; 342 return XFA_EVENTERROR_NotExist;
343 } 343 }
344 344
345 int32_t CXFA_WidgetAcc::ProcessCalculate() { 345 int32_t CXFA_WidgetAcc::ProcessCalculate() {
346 if (GetClassID() == XFA_ELEMENT_Draw) { 346 if (GetClassID() == XFA_ELEMENT_Draw)
347 return XFA_EVENTERROR_NotExist; 347 return XFA_EVENTERROR_NotExist;
348 } 348
349 CXFA_Calculate calc = GetCalculate(); 349 CXFA_Calculate calc = GetCalculate();
350 if (!calc) { 350 if (!calc)
351 return XFA_EVENTERROR_NotExist; 351 return XFA_EVENTERROR_NotExist;
352 } 352 if (GetNode()->IsUserInteractive())
353 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) {
354 return XFA_EVENTERROR_Disabled; 353 return XFA_EVENTERROR_Disabled;
355 } 354
356 CXFA_EventParam EventParam; 355 CXFA_EventParam EventParam;
357 EventParam.m_eType = XFA_EVENT_Calculate; 356 EventParam.m_eType = XFA_EVENT_Calculate;
358 CXFA_Script script = calc.GetScript(); 357 CXFA_Script script = calc.GetScript();
359 int32_t iRet = ExecuteScript(script, &EventParam); 358 int32_t iRet = ExecuteScript(script, &EventParam);
360 if (iRet != XFA_EVENTERROR_Success) 359 if (iRet != XFA_EVENTERROR_Success)
361 return iRet; 360 return iRet;
362 361
363 if (GetRawValue() != EventParam.m_wsResult) { 362 if (GetRawValue() != EventParam.m_wsResult) {
364 SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); 363 SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw);
365 UpdateUIDisplay(); 364 UpdateUIDisplay();
(...skipping 10 matching lines...) Expand all
376 IXFA_AppProvider* pAppProvider = GetAppProvider(); 375 IXFA_AppProvider* pAppProvider = GetAppProvider();
377 if (!pAppProvider) { 376 if (!pAppProvider) {
378 return; 377 return;
379 } 378 }
380 CFX_WideString wsTitle; 379 CFX_WideString wsTitle;
381 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); 380 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
382 CFX_WideString wsScriptMsg; 381 CFX_WideString wsScriptMsg;
383 validate.GetScriptMessageText(wsScriptMsg); 382 validate.GetScriptMessageText(wsScriptMsg);
384 int32_t eScriptTest = validate.GetScriptTest(); 383 int32_t eScriptTest = validate.GetScriptTest();
385 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { 384 if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) {
386 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { 385 if (GetNode()->IsUserInteractive())
387 return; 386 return;
388 } 387 if (wsScriptMsg.IsEmpty())
389 if (wsScriptMsg.IsEmpty()) {
390 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); 388 GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag);
391 } 389
392 if (bVersionFlag) { 390 if (bVersionFlag) {
393 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, 391 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
394 XFA_MB_OK); 392 XFA_MB_OK);
395 return; 393 return;
396 } 394 }
397 if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, 395 if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
398 XFA_MB_YesNo) == XFA_IDYes) { 396 XFA_MB_YesNo) == XFA_IDYes) {
399 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false); 397 GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
400 } 398 }
401 } else { 399 } else {
402 if (wsScriptMsg.IsEmpty()) { 400 if (wsScriptMsg.IsEmpty()) {
403 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); 401 GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag);
404 } 402 }
405 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); 403 pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
406 } 404 }
407 } 405 }
408 } 406 }
409 } 407 }
(...skipping 21 matching lines...) Expand all
431 CFX_WideString wsTitle; 429 CFX_WideString wsTitle;
432 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); 430 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
433 int32_t eFormatTest = validate.GetFormatTest(); 431 int32_t eFormatTest = validate.GetFormatTest();
434 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { 432 if (eFormatTest == XFA_ATTRIBUTEENUM_Error) {
435 if (wsFormatMsg.IsEmpty()) { 433 if (wsFormatMsg.IsEmpty()) {
436 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); 434 GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag);
437 } 435 }
438 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); 436 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
439 return XFA_EVENTERROR_Success; 437 return XFA_EVENTERROR_Success;
440 } 438 }
441 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { 439 if (GetNode()->IsUserInteractive())
442 return XFA_EVENTERROR_NotExist; 440 return XFA_EVENTERROR_NotExist;
443 } 441 if (wsFormatMsg.IsEmpty())
444 if (wsFormatMsg.IsEmpty()) {
445 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); 442 GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag);
446 } 443
447 if (bVersionFlag) { 444 if (bVersionFlag) {
448 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, 445 pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
449 XFA_MB_OK); 446 XFA_MB_OK);
450 return XFA_EVENTERROR_Success; 447 return XFA_EVENTERROR_Success;
451 } 448 }
452 if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, 449 if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
453 XFA_MB_YesNo) == XFA_IDYes) { 450 XFA_MB_YesNo) == XFA_IDYes) {
454 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false); 451 GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
455 } 452 }
456 return XFA_EVENTERROR_Success; 453 return XFA_EVENTERROR_Success;
457 } 454 }
458 } 455 }
459 return XFA_EVENTERROR_NotExist; 456 return XFA_EVENTERROR_NotExist;
460 } 457 }
461 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, 458 int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
462 int32_t iFlags, 459 int32_t iFlags,
463 FX_BOOL bVersionFlag) { 460 FX_BOOL bVersionFlag) {
464 CFX_WideString wsValue; 461 CFX_WideString wsValue;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 if (wsNullMsg.IsEmpty()) { 499 if (wsNullMsg.IsEmpty()) {
503 GetValidateCaptionName(wsCaptionName, bVersionFlag); 500 GetValidateCaptionName(wsCaptionName, bVersionFlag);
504 CFX_WideString wsError; 501 CFX_WideString wsError;
505 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); 502 pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError);
506 wsNullMsg.Format(wsError.c_str(), wsCaptionName.c_str()); 503 wsNullMsg.Format(wsError.c_str(), wsCaptionName.c_str());
507 } 504 }
508 pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); 505 pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
509 return XFA_EVENTERROR_Error; 506 return XFA_EVENTERROR_Error;
510 } 507 }
511 case XFA_ATTRIBUTEENUM_Warning: { 508 case XFA_ATTRIBUTEENUM_Warning: {
512 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { 509 if (GetNode()->IsUserInteractive())
513 return TRUE; 510 return TRUE;
514 } 511
515 if (wsNullMsg.IsEmpty()) { 512 if (wsNullMsg.IsEmpty()) {
516 GetValidateCaptionName(wsCaptionName, bVersionFlag); 513 GetValidateCaptionName(wsCaptionName, bVersionFlag);
517 CFX_WideString wsWarning; 514 CFX_WideString wsWarning;
518 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); 515 pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning);
519 wsNullMsg.Format(wsWarning.c_str(), wsCaptionName.c_str(), 516 wsNullMsg.Format(wsWarning.c_str(), wsCaptionName.c_str(),
520 wsCaptionName.c_str()); 517 wsCaptionName.c_str());
521 } 518 }
522 if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, 519 if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning,
523 XFA_MB_YesNo) == XFA_IDYes) { 520 XFA_MB_YesNo) == XFA_IDYes) {
524 GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false); 521 GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
525 } 522 }
526 return XFA_EVENTERROR_Error; 523 return XFA_EVENTERROR_Error;
527 } 524 }
528 case XFA_ATTRIBUTEENUM_Disabled: 525 case XFA_ATTRIBUTEENUM_Disabled:
529 default: 526 default:
530 break; 527 break;
531 } 528 }
532 return XFA_EVENTERROR_Success; 529 return XFA_EVENTERROR_Success;
533 } 530 }
534 void CXFA_WidgetAcc::GetValidateCaptionName(CFX_WideString& wsCaptionName, 531 void CXFA_WidgetAcc::GetValidateCaptionName(CFX_WideString& wsCaptionName,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 wsCaptionName.c_str()); 569 wsCaptionName.c_str());
573 } 570 }
574 int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { 571 int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
575 if (GetClassID() == XFA_ELEMENT_Draw) { 572 if (GetClassID() == XFA_ELEMENT_Draw) {
576 return XFA_EVENTERROR_NotExist; 573 return XFA_EVENTERROR_NotExist;
577 } 574 }
578 CXFA_Validate validate = GetValidate(); 575 CXFA_Validate validate = GetValidate();
579 if (!validate) { 576 if (!validate) {
580 return XFA_EVENTERROR_NotExist; 577 return XFA_EVENTERROR_NotExist;
581 } 578 }
582 FX_BOOL bInitDoc = validate.GetNode()->HasFlag(XFA_NODEFLAG_NeedsInitApp); 579 FX_BOOL bInitDoc = validate.GetNode()->NeedsInitApp();
583 FX_BOOL bStatus = 580 FX_BOOL bStatus =
584 m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; 581 m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End;
585 int32_t iFormat = 0; 582 int32_t iFormat = 0;
586 CFXJSE_Value* pRetValue = nullptr; 583 CFXJSE_Value* pRetValue = nullptr;
587 int32_t iRet = XFA_EVENTERROR_NotExist; 584 int32_t iRet = XFA_EVENTERROR_NotExist;
588 CXFA_Script script = validate.GetScript(); 585 CXFA_Script script = validate.GetScript();
589 if (script) { 586 if (script) {
590 CXFA_EventParam eParam; 587 CXFA_EventParam eParam;
591 eParam.m_eType = XFA_EVENT_Validate; 588 eParam.m_eType = XFA_EVENT_Validate;
592 eParam.m_pTarget = this; 589 eParam.m_pTarget = this;
593 iRet = ExecuteScript(script, &eParam, 590 iRet = ExecuteScript(script, &eParam,
594 ((bInitDoc || bStatus) && GetRawValue().IsEmpty()) 591 ((bInitDoc || bStatus) && GetRawValue().IsEmpty())
595 ? nullptr 592 ? nullptr
596 : &pRetValue); 593 : &pRetValue);
597 } 594 }
598 XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); 595 XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
599 FX_BOOL bVersionFlag = FALSE; 596 FX_BOOL bVersionFlag = FALSE;
600 if (version < XFA_VERSION_208) { 597 if (version < XFA_VERSION_208) {
601 bVersionFlag = TRUE; 598 bVersionFlag = TRUE;
602 } 599 }
603 if (bInitDoc) { 600 if (bInitDoc) {
604 validate.GetNode()->ClearFlag(XFA_NODEFLAG_NeedsInitApp); 601 validate.GetNode()->ClearFlag(XFA_NodeFlag_NeedsInitApp);
605 } else { 602 } else {
606 iFormat = ProcessFormatTestValidate(validate, bVersionFlag); 603 iFormat = ProcessFormatTestValidate(validate, bVersionFlag);
607 if (!bVersionFlag) { 604 if (!bVersionFlag) {
608 bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); 605 bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting);
609 } 606 }
610 iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); 607 iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag);
611 } 608 }
612 if (iFormat != XFA_EVENTERROR_Success) { 609 if (iFormat != XFA_EVENTERROR_Success) {
613 ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag); 610 ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag);
614 } 611 }
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 if (pIDNode) { 1687 if (pIDNode) {
1691 pEmbAcc = static_cast<CXFA_WidgetAcc*>(pIDNode->GetWidgetData()); 1688 pEmbAcc = static_cast<CXFA_WidgetAcc*>(pIDNode->GetWidgetData());
1692 } 1689 }
1693 if (pEmbAcc) { 1690 if (pEmbAcc) {
1694 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); 1691 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display);
1695 return TRUE; 1692 return TRUE;
1696 } 1693 }
1697 } 1694 }
1698 return FALSE; 1695 return FALSE;
1699 } 1696 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_ffwidgethandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698