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_signaturepseudomodel.h" | 7 #include "xfa/fxfa/parser/cscript_signaturepseudomodel.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 11 matching lines...) Expand all Loading... |
22 CFX_WideStringC(L"signaturePseudoModel")) {} | 22 CFX_WideStringC(L"signaturePseudoModel")) {} |
23 | 23 |
24 CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} | 24 CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} |
25 | 25 |
26 void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { | 26 void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { |
27 int32_t iLength = pArguments->GetLength(); | 27 int32_t iLength = pArguments->GetLength(); |
28 if (iLength < 1 || iLength > 4) { | 28 if (iLength < 1 || iLength > 4) { |
29 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); | 29 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); |
30 return; | 30 return; |
31 } | 31 } |
32 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 32 |
33 if (!pNotify) { | |
34 return; | |
35 } | |
36 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | |
37 CXFA_Node* pNode = nullptr; | |
38 if (iLength >= 1) { | |
39 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | |
40 } | |
41 int32_t bVerify = pNotify->GetDocProvider()->Verify(hDoc, pNode); | |
42 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 33 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
43 if (pValue) | 34 if (pValue) |
44 pValue->SetInteger(bVerify); | 35 pValue->SetInteger(0); |
45 } | 36 } |
46 | 37 |
47 void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { | 38 void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { |
48 int32_t iLength = pArguments->GetLength(); | 39 int32_t iLength = pArguments->GetLength(); |
49 if (iLength < 3 || iLength > 7) { | 40 if (iLength < 3 || iLength > 7) { |
50 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); | 41 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); |
51 return; | 42 return; |
52 } | 43 } |
53 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 44 |
54 if (!pNotify) { | |
55 return; | |
56 } | |
57 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | |
58 CXFA_NodeList* pNodeList = nullptr; | |
59 CFX_WideString wsExpression; | |
60 CFX_WideString wsXMLIdent; | |
61 if (iLength >= 1) { | |
62 pNodeList = (CXFA_NodeList*)pArguments->GetObject(0); | |
63 } | |
64 if (iLength >= 2) { | |
65 CFX_ByteString bsExpression = pArguments->GetUTF8String(1); | |
66 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | |
67 } | |
68 if (iLength >= 3) { | |
69 CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2); | |
70 wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent.AsStringC()); | |
71 } | |
72 FX_BOOL bSign = pNotify->GetDocProvider()->Sign( | |
73 hDoc, pNodeList, wsExpression.AsStringC(), wsXMLIdent.AsStringC()); | |
74 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 45 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
75 if (pValue) | 46 if (pValue) |
76 pValue->SetBoolean(bSign); | 47 pValue->SetBoolean(FALSE); |
77 } | 48 } |
78 | 49 |
79 void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { | 50 void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { |
80 int32_t iLength = pArguments->GetLength(); | 51 if (pArguments->GetLength() != 0) { |
81 if (iLength != 0) { | |
82 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); | 52 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); |
83 return; | 53 return; |
84 } | 54 } |
85 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 55 return; |
86 if (!pNotify) { | |
87 return; | |
88 } | |
89 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | |
90 CXFA_NodeList* pList = pNotify->GetDocProvider()->Enumerate(hDoc); | |
91 if (!pList) | |
92 return; | |
93 pArguments->GetReturnValue()->Assign( | |
94 m_pDocument->GetScriptContext()->GetJSValueFromMap(pList)); | |
95 } | 56 } |
96 | 57 |
97 void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) { | 58 void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) { |
98 int32_t iLength = pArguments->GetLength(); | 59 int32_t iLength = pArguments->GetLength(); |
99 if (iLength < 1 || iLength > 2) { | 60 if (iLength < 1 || iLength > 2) { |
100 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); | 61 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); |
101 return; | 62 return; |
102 } | 63 } |
103 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 64 |
104 if (!pNotify) { | |
105 return; | |
106 } | |
107 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | |
108 CXFA_Node* pNode = nullptr; | |
109 FX_BOOL bClear = TRUE; | |
110 if (iLength >= 1) { | |
111 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | |
112 } | |
113 if (iLength >= 2) { | |
114 bClear = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | |
115 } | |
116 FX_BOOL bFlag = pNotify->GetDocProvider()->Clear(hDoc, pNode, bClear); | |
117 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 65 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
118 if (pValue) | 66 if (pValue) |
119 pValue->SetBoolean(bFlag); | 67 pValue->SetBoolean(FALSE); |
120 } | 68 } |
OLD | NEW |