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/cscript_hostpseudomodel.h" | 7 #include "xfa/fxfa/parser/cscript_hostpseudomodel.h" |
8 | 8 |
9 #include "fxjs/include/cfxjse_arguments.h" | 9 #include "fxjs/include/cfxjse_arguments.h" |
10 #include "xfa/fxfa/app/xfa_ffnotify.h" | 10 #include "xfa/fxfa/app/xfa_ffnotify.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; | 321 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; |
322 } | 322 } |
323 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( | 323 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( |
324 wsQuestion, wsTitle, wsDefaultAnswer, bMark); | 324 wsQuestion, wsTitle, wsDefaultAnswer, bMark); |
325 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 325 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
326 if (pValue) | 326 if (pValue) |
327 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); | 327 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); |
328 } | 328 } |
329 | 329 |
330 void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { | 330 void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { |
331 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 331 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) |
332 if (!pNotify) { | 332 pValue->SetInteger(0); |
333 return; | |
334 } | |
335 int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); | |
336 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | |
337 if (pValue) | |
338 pValue->SetInteger(iCur); | |
339 } | 333 } |
340 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, | 334 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, |
341 int32_t nStart, | 335 int32_t nStart, |
342 CFX_WideString& wsFilter) { | 336 CFX_WideString& wsFilter) { |
343 ASSERT(nStart > -1); | 337 ASSERT(nStart > -1); |
344 int32_t iLength = wsExpression.GetLength(); | 338 int32_t iLength = wsExpression.GetLength(); |
345 if (nStart >= iLength) { | 339 if (nStart >= iLength) { |
346 return iLength; | 340 return iLength; |
347 } | 341 } |
348 FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart); | 342 FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 539 } |
546 if (pValueArg->IsNull()) { | 540 if (pValueArg->IsNull()) { |
547 wsValue = FX_WSTRC(L""); | 541 wsValue = FX_WSTRC(L""); |
548 } else { | 542 } else { |
549 wsValue = pValueArg->ToWideString(); | 543 wsValue = pValueArg->ToWideString(); |
550 } | 544 } |
551 return TRUE; | 545 return TRUE; |
552 } | 546 } |
553 void CScript_HostPseudoModel::DocumentCountInBatch( | 547 void CScript_HostPseudoModel::DocumentCountInBatch( |
554 CFXJSE_Arguments* pArguments) { | 548 CFXJSE_Arguments* pArguments) { |
555 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 549 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) |
556 if (!pNotify) { | 550 pValue->SetInteger(0); |
557 return; | |
558 } | |
559 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); | |
560 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | |
561 if (pValue) | |
562 pValue->SetInteger(iValue); | |
563 } | 551 } |
564 void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { | 552 void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { |
565 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 553 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
566 return; | 554 return; |
567 } | 555 } |
568 int32_t iLength = pArguments->GetLength(); | 556 int32_t iLength = pArguments->GetLength(); |
569 if (iLength != 8) { | 557 if (iLength != 8) { |
570 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); | 558 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); |
571 return; | 559 return; |
572 } | 560 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { | 688 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { |
701 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 689 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
702 if (!pNotify) { | 690 if (!pNotify) { |
703 return; | 691 return; |
704 } | 692 } |
705 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 693 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
706 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 694 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
707 if (pValue) | 695 if (pValue) |
708 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 696 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
709 } | 697 } |
OLD | NEW |