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