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

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

Issue 1668003003: Call CXFA_Object::ToNode() rather than C-style casting. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 10 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
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/src/foxitlib.h" 7 #include "xfa/src/foxitlib.h"
8 #include "xfa/src/fxfa/src/common/xfa_utils.h" 8 #include "xfa/src/fxfa/src/common/xfa_utils.h"
9 #include "xfa/src/fxfa/src/common/xfa_object.h" 9 #include "xfa/src/fxfa/src/common/xfa_object.h"
10 #include "xfa/src/fxfa/src/common/xfa_document.h" 10 #include "xfa/src/fxfa/src/common/xfa_document.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return; 298 return;
299 } 299 }
300 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); 300 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify();
301 if (!pNotify) { 301 if (!pNotify) {
302 return; 302 return;
303 } 303 }
304 CXFA_Node* pNode = NULL; 304 CXFA_Node* pNode = NULL;
305 if (iLength >= 1) { 305 if (iLength >= 1) {
306 FXJSE_HVALUE hValue = pArguments->GetValue(0); 306 FXJSE_HVALUE hValue = pArguments->GetValue(0);
307 if (FXJSE_Value_IsObject(hValue)) { 307 if (FXJSE_Value_IsObject(hValue)) {
308 pNode = (CXFA_Node*)FXJSE_Value_ToObject(hValue, NULL); 308 pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, nullptr));
309 } else if (FXJSE_Value_IsUTF8String(hValue)) { 309 } else if (FXJSE_Value_IsUTF8String(hValue)) {
310 CFX_ByteString bsString; 310 CFX_ByteString bsString;
311 FXJSE_Value_ToUTF8String(hValue, bsString); 311 FXJSE_Value_ToUTF8String(hValue, bsString);
312 CFX_WideString wsExpression = 312 CFX_WideString wsExpression =
313 CFX_WideString::FromUTF8(bsString, bsString.GetLength()); 313 CFX_WideString::FromUTF8(bsString, bsString.GetLength());
314 IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 314 IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
315 if (!pScriptContext) { 315 if (!pScriptContext) {
316 FXJSE_Value_Release(hValue); 316 FXJSE_Value_Release(hValue);
317 return; 317 return;
318 } 318 }
319 CXFA_Object* pObject = pScriptContext->GetThisObject(); 319 CXFA_Object* pObject = pScriptContext->GetThisObject();
320 if (!pObject) { 320 if (!pObject) {
321 FXJSE_Value_Release(hValue); 321 FXJSE_Value_Release(hValue);
322 return; 322 return;
323 } 323 }
324 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | 324 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
325 XFA_RESOLVENODE_Siblings; 325 XFA_RESOLVENODE_Siblings;
326 XFA_RESOLVENODE_RS resoveNodeRS; 326 XFA_RESOLVENODE_RS resoveNodeRS;
327 int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, 327 int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression,
328 resoveNodeRS, dwFlag); 328 resoveNodeRS, dwFlag);
329 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { 329 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
330 FXJSE_Value_Release(hValue); 330 FXJSE_Value_Release(hValue);
331 return; 331 return;
332 } 332 }
333 pNode = (CXFA_Node*)resoveNodeRS.nodes[0]; 333 pNode = resoveNodeRS.nodes[0]->AsNode();
334 } 334 }
335 FXJSE_Value_Release(hValue); 335 FXJSE_Value_Release(hValue);
336 } 336 }
337 IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); 337 IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout();
338 if (!pDocLayout) { 338 if (!pDocLayout) {
339 return; 339 return;
340 } 340 }
341 IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); 341 IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
342 if (!hWidget) { 342 if (!hWidget) {
343 return; 343 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return; 456 return;
457 } 457 }
458 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | 458 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
459 XFA_RESOLVENODE_Siblings; 459 XFA_RESOLVENODE_Siblings;
460 XFA_RESOLVENODE_RS resoveNodeRS; 460 XFA_RESOLVENODE_RS resoveNodeRS;
461 int32_t iRet = 461 int32_t iRet =
462 pScriptContext->ResolveObjects(pObject, wsName, resoveNodeRS, dwFlag); 462 pScriptContext->ResolveObjects(pObject, wsName, resoveNodeRS, dwFlag);
463 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { 463 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
464 continue; 464 continue;
465 } 465 }
466 pNode = (CXFA_Node*)resoveNodeRS.nodes[0]; 466 pNode = resoveNodeRS.nodes[0]->AsNode();
467 pNotify->ResetData(pNode->GetWidgetData()); 467 pNotify->ResetData(pNode->GetWidgetData());
468 } 468 }
469 if (!pNode) { 469 if (!pNode) {
470 pNotify->ResetData(); 470 pNotify->ResetData();
471 } 471 }
472 } 472 }
473 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( 473 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep(
474 CFXJSE_Arguments* pArguments) { 474 CFXJSE_Arguments* pArguments) {
475 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 475 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
476 return; 476 return;
(...skipping 24 matching lines...) Expand all
501 return; 501 return;
502 } 502 }
503 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); 503 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify();
504 if (!pNotify) { 504 if (!pNotify) {
505 return; 505 return;
506 } 506 }
507 CXFA_Node* pNode = NULL; 507 CXFA_Node* pNode = NULL;
508 if (iLength >= 1) { 508 if (iLength >= 1) {
509 FXJSE_HVALUE hValue = pArguments->GetValue(0); 509 FXJSE_HVALUE hValue = pArguments->GetValue(0);
510 if (FXJSE_Value_IsObject(hValue)) { 510 if (FXJSE_Value_IsObject(hValue)) {
511 pNode = (CXFA_Node*)FXJSE_Value_ToObject(hValue, NULL); 511 pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, NULL));
512 } else if (FXJSE_Value_IsUTF8String(hValue)) { 512 } else if (FXJSE_Value_IsUTF8String(hValue)) {
513 CFX_ByteString bsString; 513 CFX_ByteString bsString;
514 FXJSE_Value_ToUTF8String(hValue, bsString); 514 FXJSE_Value_ToUTF8String(hValue, bsString);
515 CFX_WideString wsExpression = 515 CFX_WideString wsExpression =
516 CFX_WideString::FromUTF8(bsString, bsString.GetLength()); 516 CFX_WideString::FromUTF8(bsString, bsString.GetLength());
517 IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 517 IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
518 if (!pScriptContext) { 518 if (!pScriptContext) {
519 FXJSE_Value_Release(hValue); 519 FXJSE_Value_Release(hValue);
520 return; 520 return;
521 } 521 }
522 CXFA_Object* pObject = pScriptContext->GetThisObject(); 522 CXFA_Object* pObject = pScriptContext->GetThisObject();
523 if (!pObject) { 523 if (!pObject) {
524 FXJSE_Value_Release(hValue); 524 FXJSE_Value_Release(hValue);
525 return; 525 return;
526 } 526 }
527 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | 527 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
528 XFA_RESOLVENODE_Siblings; 528 XFA_RESOLVENODE_Siblings;
529 XFA_RESOLVENODE_RS resoveNodeRS; 529 XFA_RESOLVENODE_RS resoveNodeRS;
530 int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, 530 int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression,
531 resoveNodeRS, dwFlag); 531 resoveNodeRS, dwFlag);
532 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { 532 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
533 FXJSE_Value_Release(hValue); 533 FXJSE_Value_Release(hValue);
534 return; 534 return;
535 } 535 }
536 pNode = (CXFA_Node*)resoveNodeRS.nodes[0]; 536 pNode = resoveNodeRS.nodes[0]->AsNode();
537 } 537 }
538 FXJSE_Value_Release(hValue); 538 FXJSE_Value_Release(hValue);
539 } 539 }
540 pNotify->SetFocusWidgetNode(pNode); 540 pNotify->SetFocusWidgetNode(pNode);
541 } 541 }
542 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( 542 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus(
543 CFXJSE_Arguments* pArguments) { 543 CFXJSE_Arguments* pArguments) {
544 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); 544 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify();
545 if (!pNotify) { 545 if (!pNotify) {
546 return; 546 return;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); 790 IXFA_Notify* 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 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); 795 FXJSE_HVALUE hValue = pArguments->GetReturnValue();
796 if (hValue) { 796 if (hValue) {
797 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime)); 797 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime));
798 } 798 }
799 } 799 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698