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