Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | c1515ef | 2016-07-20 06:16:06 -0700 | [diff] [blame] | 7 | #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 8 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 9 | #include "fxjs/cfxjse_arguments.h" |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 10 | #include "xfa/fxfa/app/xfa_ffnotify.h" |
dsinclair | 1628024 | 2016-07-21 12:03:47 -0700 | [diff] [blame] | 11 | #include "xfa/fxfa/parser/cxfa_document.h" |
dsinclair | 31f8740 | 2016-07-20 06:34:45 -0700 | [diff] [blame] | 12 | #include "xfa/fxfa/parser/cxfa_scriptcontext.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 13 | #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 14 | #include "xfa/fxfa/parser/xfa_object.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 15 | #include "xfa/fxfa/parser/xfa_utils.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | |
| 17 | CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( |
| 18 | CXFA_Document* pDocument) |
dsinclair | 937a113 | 2016-06-23 07:52:01 -0700 | [diff] [blame] | 19 | : CXFA_Object(pDocument, |
| 20 | XFA_ObjectType::Object, |
dsinclair | c1df5d4 | 2016-07-18 06:36:51 -0700 | [diff] [blame] | 21 | XFA_Element::SignaturePseudoModel, |
| 22 | CFX_WideStringC(L"signaturePseudoModel")) {} |
| 23 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 24 | CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} |
dsinclair | c1df5d4 | 2016-07-18 06:36:51 -0700 | [diff] [blame] | 25 | |
dsinclair | d1cf239 | 2016-07-11 06:46:59 -0700 | [diff] [blame] | 26 | void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 27 | int32_t iLength = pArguments->GetLength(); |
| 28 | if (iLength < 1 || iLength > 4) { |
dsinclair | 2235b7b | 2016-06-02 07:42:25 -0700 | [diff] [blame] | 29 | ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 30 | return; |
| 31 | } |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 32 | |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 33 | CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
dsinclair | f27aeec | 2016-06-07 19:36:18 -0700 | [diff] [blame] | 34 | if (pValue) |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 35 | pValue->SetInteger(0); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 36 | } |
dsinclair | c1df5d4 | 2016-07-18 06:36:51 -0700 | [diff] [blame] | 37 | |
dsinclair | d1cf239 | 2016-07-11 06:46:59 -0700 | [diff] [blame] | 38 | void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 39 | int32_t iLength = pArguments->GetLength(); |
| 40 | if (iLength < 3 || iLength > 7) { |
dsinclair | 2235b7b | 2016-06-02 07:42:25 -0700 | [diff] [blame] | 41 | ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 42 | return; |
| 43 | } |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 44 | |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 45 | CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
dsinclair | f27aeec | 2016-06-07 19:36:18 -0700 | [diff] [blame] | 46 | if (pValue) |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 47 | pValue->SetBoolean(FALSE); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 48 | } |
dsinclair | c1df5d4 | 2016-07-18 06:36:51 -0700 | [diff] [blame] | 49 | |
dsinclair | d1cf239 | 2016-07-11 06:46:59 -0700 | [diff] [blame] | 50 | void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 51 | if (pArguments->GetLength() != 0) { |
dsinclair | 2235b7b | 2016-06-02 07:42:25 -0700 | [diff] [blame] | 52 | ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 53 | return; |
| 54 | } |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 55 | return; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 56 | } |
dsinclair | c1df5d4 | 2016-07-18 06:36:51 -0700 | [diff] [blame] | 57 | |
dsinclair | d1cf239 | 2016-07-11 06:46:59 -0700 | [diff] [blame] | 58 | void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 59 | int32_t iLength = pArguments->GetLength(); |
| 60 | if (iLength < 1 || iLength > 2) { |
dsinclair | 2235b7b | 2016-06-02 07:42:25 -0700 | [diff] [blame] | 61 | ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 62 | return; |
| 63 | } |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 64 | |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 65 | CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
dsinclair | f27aeec | 2016-06-07 19:36:18 -0700 | [diff] [blame] | 66 | if (pValue) |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 67 | pValue->SetBoolean(FALSE); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 68 | } |