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 "xfa/fxfa/app/xfa_ffnotify.h" | 9 #include "xfa/fxfa/app/xfa_ffnotify.h" |
10 #include "xfa/fxfa/parser/xfa_doclayout.h" | 10 #include "xfa/fxfa/parser/xfa_doclayout.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 if (!pNotify) { | 35 if (!pNotify) { |
36 return; | 36 return; |
37 } | 37 } |
38 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 38 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
39 CXFA_Node* pNode = NULL; | 39 CXFA_Node* pNode = NULL; |
40 if (iLength >= 1) { | 40 if (iLength >= 1) { |
41 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 41 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
42 } | 42 } |
43 int32_t bVerify = pNotify->GetDocProvider()->Verify(hDoc, pNode); | 43 int32_t bVerify = pNotify->GetDocProvider()->Verify(hDoc, pNode); |
44 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 44 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
45 if (pValue) { | 45 if (pValue) |
46 FXJSE_Value_SetInteger(pValue, bVerify); | 46 pValue->SetInteger(bVerify); |
47 } | |
48 } | 47 } |
49 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Sign( | 48 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Sign( |
50 CFXJSE_Arguments* pArguments) { | 49 CFXJSE_Arguments* pArguments) { |
51 int32_t iLength = pArguments->GetLength(); | 50 int32_t iLength = pArguments->GetLength(); |
52 if (iLength < 3 || iLength > 7) { | 51 if (iLength < 3 || iLength > 7) { |
53 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); | 52 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); |
54 return; | 53 return; |
55 } | 54 } |
56 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 55 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
57 if (!pNotify) { | 56 if (!pNotify) { |
(...skipping 10 matching lines...) Expand all Loading... |
68 CFX_ByteString bsExpression = pArguments->GetUTF8String(1); | 67 CFX_ByteString bsExpression = pArguments->GetUTF8String(1); |
69 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 68 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); |
70 } | 69 } |
71 if (iLength >= 3) { | 70 if (iLength >= 3) { |
72 CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2); | 71 CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2); |
73 wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent.AsStringC()); | 72 wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent.AsStringC()); |
74 } | 73 } |
75 FX_BOOL bSign = pNotify->GetDocProvider()->Sign( | 74 FX_BOOL bSign = pNotify->GetDocProvider()->Sign( |
76 hDoc, pNodeList, wsExpression.AsStringC(), wsXMLIdent.AsStringC()); | 75 hDoc, pNodeList, wsExpression.AsStringC(), wsXMLIdent.AsStringC()); |
77 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 76 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
78 if (pValue) { | 77 if (pValue) |
79 FXJSE_Value_SetBoolean(pValue, bSign); | 78 pValue->SetBoolean(bSign); |
80 } | |
81 } | 79 } |
82 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Enumerate( | 80 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Enumerate( |
83 CFXJSE_Arguments* pArguments) { | 81 CFXJSE_Arguments* pArguments) { |
84 int32_t iLength = pArguments->GetLength(); | 82 int32_t iLength = pArguments->GetLength(); |
85 if (iLength != 0) { | 83 if (iLength != 0) { |
86 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); | 84 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); |
87 return; | 85 return; |
88 } | 86 } |
89 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 87 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
90 if (!pNotify) { | 88 if (!pNotify) { |
91 return; | 89 return; |
92 } | 90 } |
93 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 91 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
94 CXFA_NodeList* pList = pNotify->GetDocProvider()->Enumerate(hDoc); | 92 CXFA_NodeList* pList = pNotify->GetDocProvider()->Enumerate(hDoc); |
95 if (!pList) | 93 if (!pList) |
96 return; | 94 return; |
97 FXJSE_Value_Set(pArguments->GetReturnValue(), | 95 pArguments->GetReturnValue()->Assign( |
98 m_pDocument->GetScriptContext()->GetJSValueFromMap(pList)); | 96 m_pDocument->GetScriptContext()->GetJSValueFromMap(pList)); |
99 } | 97 } |
100 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Clear( | 98 void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Clear( |
101 CFXJSE_Arguments* pArguments) { | 99 CFXJSE_Arguments* pArguments) { |
102 int32_t iLength = pArguments->GetLength(); | 100 int32_t iLength = pArguments->GetLength(); |
103 if (iLength < 1 || iLength > 2) { | 101 if (iLength < 1 || iLength > 2) { |
104 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); | 102 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); |
105 return; | 103 return; |
106 } | 104 } |
107 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 105 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
108 if (!pNotify) { | 106 if (!pNotify) { |
109 return; | 107 return; |
110 } | 108 } |
111 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 109 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
112 CXFA_Node* pNode = NULL; | 110 CXFA_Node* pNode = NULL; |
113 FX_BOOL bClear = TRUE; | 111 FX_BOOL bClear = TRUE; |
114 if (iLength >= 1) { | 112 if (iLength >= 1) { |
115 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 113 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
116 } | 114 } |
117 if (iLength >= 2) { | 115 if (iLength >= 2) { |
118 bClear = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | 116 bClear = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; |
119 } | 117 } |
120 FX_BOOL bFlag = pNotify->GetDocProvider()->Clear(hDoc, pNode, bClear); | 118 FX_BOOL bFlag = pNotify->GetDocProvider()->Clear(hDoc, pNode, bClear); |
121 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 119 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
122 if (pValue) { | 120 if (pValue) |
123 FXJSE_Value_SetBoolean(pValue, bFlag); | 121 pValue->SetBoolean(bFlag); |
124 } | |
125 } | 122 } |
OLD | NEW |