Chromium Code Reviews

Side by Side Diff: xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « xfa/fxfa/parser/xfa_script.h ('k') | xfa/fxfa/parser/xfa_script_imp.h » ('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/parser/xfa_script_hostpseudomodel.h" 7 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffnotify.h" 9 #include "xfa/fxfa/app/xfa_ffnotify.h"
10 #include "xfa/fxfa/parser/xfa_doclayout.h" 10 #include "xfa/fxfa/parser/xfa_doclayout.h"
(...skipping 295 matching lines...)
306 } 306 }
307 int32_t iLength = pArguments->GetLength(); 307 int32_t iLength = pArguments->GetLength();
308 if (iLength != 1) { 308 if (iLength != 1) {
309 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); 309 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList");
310 return; 310 return;
311 } 311 }
312 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 312 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
313 if (!pNotify) { 313 if (!pNotify) {
314 return; 314 return;
315 } 315 }
316 CXFA_Node* pNode = NULL; 316 CXFA_Node* pNode = nullptr;
317 if (iLength >= 1) { 317 if (iLength >= 1) {
318 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); 318 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
319 if (FXJSE_Value_IsObject(pValue.get())) { 319 if (FXJSE_Value_IsObject(pValue.get())) {
320 pNode = ToNode(pValue.get(), nullptr); 320 pNode = ToNode(pValue.get(), nullptr);
321 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { 321 } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
322 CFX_ByteString bsString; 322 CFX_ByteString bsString;
323 FXJSE_Value_ToUTF8String(pValue.get(), bsString); 323 FXJSE_Value_ToUTF8String(pValue.get(), bsString);
324 CFX_WideString wsExpression = 324 CFX_WideString wsExpression =
325 CFX_WideString::FromUTF8(bsString.AsStringC()); 325 CFX_WideString::FromUTF8(bsString.AsStringC());
326 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 326 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
(...skipping 115 matching lines...)
442 if (iLength >= 1) { 442 if (iLength >= 1) {
443 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); 443 CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
444 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); 444 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
445 } 445 }
446 if (wsExpression.IsEmpty()) { 446 if (wsExpression.IsEmpty()) {
447 pNotify->ResetData(); 447 pNotify->ResetData();
448 return; 448 return;
449 } 449 }
450 int32_t iStart = 0; 450 int32_t iStart = 0;
451 CFX_WideString wsName; 451 CFX_WideString wsName;
452 CXFA_Node* pNode = NULL; 452 CXFA_Node* pNode = nullptr;
453 int32_t iExpLength = wsExpression.GetLength(); 453 int32_t iExpLength = wsExpression.GetLength();
454 while (iStart < iExpLength) { 454 while (iStart < iExpLength) {
455 iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName); 455 iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName);
456 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 456 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
457 if (!pScriptContext) { 457 if (!pScriptContext) {
458 return; 458 return;
459 } 459 }
460 CXFA_Object* pObject = pScriptContext->GetThisObject(); 460 CXFA_Object* pObject = pScriptContext->GetThisObject();
461 if (!pObject) { 461 if (!pObject) {
462 return; 462 return;
(...skipping 40 matching lines...)
503 } 503 }
504 int32_t iLength = pArguments->GetLength(); 504 int32_t iLength = pArguments->GetLength();
505 if (iLength != 1) { 505 if (iLength != 1) {
506 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); 506 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus");
507 return; 507 return;
508 } 508 }
509 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 509 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
510 if (!pNotify) { 510 if (!pNotify) {
511 return; 511 return;
512 } 512 }
513 CXFA_Node* pNode = NULL; 513 CXFA_Node* pNode = nullptr;
514 if (iLength >= 1) { 514 if (iLength >= 1) {
515 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); 515 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
516 if (FXJSE_Value_IsObject(pValue.get())) { 516 if (FXJSE_Value_IsObject(pValue.get())) {
517 pNode = ToNode(pValue.get(), nullptr); 517 pNode = ToNode(pValue.get(), nullptr);
518 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { 518 } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
519 CFX_ByteString bsString; 519 CFX_ByteString bsString;
520 FXJSE_Value_ToUTF8String(pValue.get(), bsString); 520 FXJSE_Value_ToUTF8String(pValue.get(), bsString);
521 CFX_WideString wsExpression = 521 CFX_WideString wsExpression =
522 CFX_WideString::FromUTF8(bsString.AsStringC()); 522 CFX_WideString::FromUTF8(bsString.AsStringC());
523 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 523 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
(...skipping 74 matching lines...)
598 wsMessage, bsTitle, dwMessageType, dwButtonType); 598 wsMessage, bsTitle, dwMessageType, dwButtonType);
599 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 599 CFXJSE_Value* pValue = pArguments->GetReturnValue();
600 if (pValue) { 600 if (pValue) {
601 FXJSE_Value_SetInteger(pValue, iValue); 601 FXJSE_Value_SetInteger(pValue, iValue);
602 } 602 }
603 } 603 }
604 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( 604 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg(
605 CFXJSE_Arguments* pArguments, 605 CFXJSE_Arguments* pArguments,
606 int32_t iArgIndex, 606 int32_t iArgIndex,
607 CFX_WideString& wsValue) { 607 CFX_WideString& wsValue) {
608 if (pArguments == NULL || iArgIndex < 0) { 608 if (!pArguments || iArgIndex < 0)
609 return FALSE; 609 return FALSE;
610 } 610
611 FX_BOOL bIsJsType = FALSE; 611 FX_BOOL bIsJsType = FALSE;
612 if (m_pDocument->GetScriptContext()->GetType() == 612 if (m_pDocument->GetScriptContext()->GetType() ==
613 XFA_SCRIPTLANGTYPE_Javascript) { 613 XFA_SCRIPTLANGTYPE_Javascript) {
614 bIsJsType = TRUE; 614 bIsJsType = TRUE;
615 } 615 }
616 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); 616 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex));
617 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { 617 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) {
618 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 618 ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
619 return FALSE; 619 return FALSE;
620 } 620 }
(...skipping 169 matching lines...)
790 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 790 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
791 if (!pNotify) { 791 if (!pNotify) {
792 return; 792 return;
793 } 793 }
794 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); 794 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime();
795 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 795 CFXJSE_Value* pValue = pArguments->GetReturnValue();
796 if (pValue) { 796 if (pValue) {
797 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); 797 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC());
798 } 798 }
799 } 799 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script.h ('k') | xfa/fxfa/parser/xfa_script_imp.h » ('j') | no next file with comments »

Powered by Google App Engine