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