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