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/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" |
11 #include "xfa/fxfa/parser/xfa_document.h" | 11 #include "xfa/fxfa/parser/xfa_document.h" |
12 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 12 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
13 #include "xfa/fxfa/parser/xfa_localemgr.h" | 13 #include "xfa/fxfa/parser/xfa_localemgr.h" |
14 #include "xfa/fxfa/parser/xfa_object.h" | 14 #include "xfa/fxfa/parser/xfa_object.h" |
15 #include "xfa/fxfa/parser/xfa_parser.h" | 15 #include "xfa/fxfa/parser/xfa_parser.h" |
16 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 16 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
17 #include "xfa/fxfa/parser/xfa_script.h" | 17 #include "xfa/fxfa/parser/xfa_script.h" |
18 #include "xfa/fxfa/parser/xfa_script_imp.h" | 18 #include "xfa/fxfa/parser/xfa_script_imp.h" |
19 #include "xfa/fxfa/parser/xfa_utils.h" | 19 #include "xfa/fxfa/parser/xfa_utils.h" |
20 #include "xfa/fxjse/cfxjse_arguments.h" | 20 #include "xfa/fxjse/cfxjse_arguments.h" |
21 | 21 |
| 22 namespace { |
| 23 |
| 24 CXFA_Node* ToNode(CFXJSE_Value* pValue, CFXJSE_Class* pClass) { |
| 25 return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass)); |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
22 CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) | 30 CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) |
23 : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) { | 31 : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) { |
24 m_uScriptHash = XFA_HASHCODE_Host; | 32 m_uScriptHash = XFA_HASHCODE_Host; |
25 } | 33 } |
26 CScript_HostPseudoModel::~CScript_HostPseudoModel() {} | 34 CScript_HostPseudoModel::~CScript_HostPseudoModel() {} |
27 void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( | 35 void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( |
28 CFXJSE_Value* pValue, | 36 CFXJSE_Value* pValue, |
29 CXFA_FFNotify* pNotify, | 37 CXFA_FFNotify* pNotify, |
30 uint32_t dwFlag) { | 38 uint32_t dwFlag) { |
31 CFX_WideString wsValue; | 39 CFX_WideString wsValue; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return; | 310 return; |
303 } | 311 } |
304 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 312 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
305 if (!pNotify) { | 313 if (!pNotify) { |
306 return; | 314 return; |
307 } | 315 } |
308 CXFA_Node* pNode = NULL; | 316 CXFA_Node* pNode = NULL; |
309 if (iLength >= 1) { | 317 if (iLength >= 1) { |
310 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 318 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
311 if (FXJSE_Value_IsObject(pValue.get())) { | 319 if (FXJSE_Value_IsObject(pValue.get())) { |
312 pNode = | 320 pNode = ToNode(pValue.get(), nullptr); |
313 static_cast<CXFA_Node*>(FXJSE_Value_ToObject(pValue.get(), nullptr)); | |
314 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { | 321 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { |
315 CFX_ByteString bsString; | 322 CFX_ByteString bsString; |
316 FXJSE_Value_ToUTF8String(pValue.get(), bsString); | 323 FXJSE_Value_ToUTF8String(pValue.get(), bsString); |
317 CFX_WideString wsExpression = | 324 CFX_WideString wsExpression = |
318 CFX_WideString::FromUTF8(bsString.AsStringC()); | 325 CFX_WideString::FromUTF8(bsString.AsStringC()); |
319 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 326 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
320 if (!pScriptContext) | 327 if (!pScriptContext) |
321 return; | 328 return; |
322 | 329 |
323 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 330 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return; | 507 return; |
501 } | 508 } |
502 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 509 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
503 if (!pNotify) { | 510 if (!pNotify) { |
504 return; | 511 return; |
505 } | 512 } |
506 CXFA_Node* pNode = NULL; | 513 CXFA_Node* pNode = NULL; |
507 if (iLength >= 1) { | 514 if (iLength >= 1) { |
508 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 515 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
509 if (FXJSE_Value_IsObject(pValue.get())) { | 516 if (FXJSE_Value_IsObject(pValue.get())) { |
510 pNode = | 517 pNode = ToNode(pValue.get(), nullptr); |
511 static_cast<CXFA_Node*>(FXJSE_Value_ToObject(pValue.get(), nullptr)); | |
512 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { | 518 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { |
513 CFX_ByteString bsString; | 519 CFX_ByteString bsString; |
514 FXJSE_Value_ToUTF8String(pValue.get(), bsString); | 520 FXJSE_Value_ToUTF8String(pValue.get(), bsString); |
515 CFX_WideString wsExpression = | 521 CFX_WideString wsExpression = |
516 CFX_WideString::FromUTF8(bsString.AsStringC()); | 522 CFX_WideString::FromUTF8(bsString.AsStringC()); |
517 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 523 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
518 if (!pScriptContext) | 524 if (!pScriptContext) |
519 return; | 525 return; |
520 | 526 |
521 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 527 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 790 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
785 if (!pNotify) { | 791 if (!pNotify) { |
786 return; | 792 return; |
787 } | 793 } |
788 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 794 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
789 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 795 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
790 if (pValue) { | 796 if (pValue) { |
791 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); | 797 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); |
792 } | 798 } |
793 } | 799 } |
OLD | NEW |