blob: 5a484ab12c08e6d0cb1bf60fe2b614618eb7d02e [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
dsinclairc1515ef2016-07-20 06:16:06 -07007#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
Dan Sinclair1770c022016-03-14 14:14:16 -04008
dsinclair43554682016-09-29 17:29:48 -07009#include "fxjs/cfxjse_arguments.h"
dsinclairdf4bc592016-03-31 20:34:43 -070010#include "xfa/fxfa/app/xfa_ffnotify.h"
dsinclair16280242016-07-21 12:03:47 -070011#include "xfa/fxfa/parser/cxfa_document.h"
dsinclair31f87402016-07-20 06:34:45 -070012#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040013#include "xfa/fxfa/parser/xfa_localemgr.h"
14#include "xfa/fxfa/parser/xfa_object.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040015#include "xfa/fxfa/parser/xfa_utils.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040016
17CScript_SignaturePseudoModel::CScript_SignaturePseudoModel(
18 CXFA_Document* pDocument)
dsinclair937a1132016-06-23 07:52:01 -070019 : CXFA_Object(pDocument,
20 XFA_ObjectType::Object,
dsinclairc1df5d42016-07-18 06:36:51 -070021 XFA_Element::SignaturePseudoModel,
22 CFX_WideStringC(L"signaturePseudoModel")) {}
23
Dan Sinclair1770c022016-03-14 14:14:16 -040024CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {}
dsinclairc1df5d42016-07-18 06:36:51 -070025
dsinclaird1cf2392016-07-11 06:46:59 -070026void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
Dan Sinclair1770c022016-03-14 14:14:16 -040027 int32_t iLength = pArguments->GetLength();
28 if (iLength < 1 || iLength > 4) {
dsinclair2235b7b2016-06-02 07:42:25 -070029 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify");
Dan Sinclair1770c022016-03-14 14:14:16 -040030 return;
31 }
dsinclair89f8fa82016-09-14 06:11:08 -070032
dsinclair12a6b0c2016-05-26 11:14:08 -070033 CFXJSE_Value* pValue = pArguments->GetReturnValue();
dsinclairf27aeec2016-06-07 19:36:18 -070034 if (pValue)
dsinclair89f8fa82016-09-14 06:11:08 -070035 pValue->SetInteger(0);
Dan Sinclair1770c022016-03-14 14:14:16 -040036}
dsinclairc1df5d42016-07-18 06:36:51 -070037
dsinclaird1cf2392016-07-11 06:46:59 -070038void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
Dan Sinclair1770c022016-03-14 14:14:16 -040039 int32_t iLength = pArguments->GetLength();
40 if (iLength < 3 || iLength > 7) {
dsinclair2235b7b2016-06-02 07:42:25 -070041 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign");
Dan Sinclair1770c022016-03-14 14:14:16 -040042 return;
43 }
dsinclair89f8fa82016-09-14 06:11:08 -070044
dsinclair12a6b0c2016-05-26 11:14:08 -070045 CFXJSE_Value* pValue = pArguments->GetReturnValue();
dsinclairf27aeec2016-06-07 19:36:18 -070046 if (pValue)
dsinclair89f8fa82016-09-14 06:11:08 -070047 pValue->SetBoolean(FALSE);
Dan Sinclair1770c022016-03-14 14:14:16 -040048}
dsinclairc1df5d42016-07-18 06:36:51 -070049
dsinclaird1cf2392016-07-11 06:46:59 -070050void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
dsinclair89f8fa82016-09-14 06:11:08 -070051 if (pArguments->GetLength() != 0) {
dsinclair2235b7b2016-06-02 07:42:25 -070052 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate");
Dan Sinclair1770c022016-03-14 14:14:16 -040053 return;
54 }
dsinclair89f8fa82016-09-14 06:11:08 -070055 return;
Dan Sinclair1770c022016-03-14 14:14:16 -040056}
dsinclairc1df5d42016-07-18 06:36:51 -070057
dsinclaird1cf2392016-07-11 06:46:59 -070058void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) {
Dan Sinclair1770c022016-03-14 14:14:16 -040059 int32_t iLength = pArguments->GetLength();
60 if (iLength < 1 || iLength > 2) {
dsinclair2235b7b2016-06-02 07:42:25 -070061 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear");
Dan Sinclair1770c022016-03-14 14:14:16 -040062 return;
63 }
dsinclair89f8fa82016-09-14 06:11:08 -070064
dsinclair12a6b0c2016-05-26 11:14:08 -070065 CFXJSE_Value* pValue = pArguments->GetReturnValue();
dsinclairf27aeec2016-06-07 19:36:18 -070066 if (pValue)
dsinclair89f8fa82016-09-14 06:11:08 -070067 pValue->SetBoolean(FALSE);
Dan Sinclair1770c022016-03-14 14:14:16 -040068}