| 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_hostpseudomodel.h" | 7 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 if (bSetting) { | 48 if (bSetting) { |
| 49 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 49 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 CFX_WideString wsAppType; | 52 CFX_WideString wsAppType; |
| 53 pNotify->GetAppProvider()->GetAppType(wsAppType); | 53 pNotify->GetAppProvider()->GetAppType(wsAppType); |
| 54 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); | 54 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void CScript_HostPseudoModel::FoxitAppType(CFXJSE_Value* pValue, | |
| 58 FX_BOOL bSetting, | |
| 59 XFA_ATTRIBUTE eAttribute) { | |
| 60 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | |
| 61 if (!pNotify) { | |
| 62 return; | |
| 63 } | |
| 64 if (bSetting) { | |
| 65 ThrowException(XFA_IDS_INVAlID_PROP_SET); | |
| 66 return; | |
| 67 } | |
| 68 CFX_WideString wsAppType; | |
| 69 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); | |
| 70 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); | |
| 71 } | |
| 72 | |
| 73 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, | 57 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, |
| 74 FX_BOOL bSetting, | 58 FX_BOOL bSetting, |
| 75 XFA_ATTRIBUTE eAttribute) { | 59 XFA_ATTRIBUTE eAttribute) { |
| 76 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 60 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
| 77 if (!pNotify) { | 61 if (!pNotify) { |
| 78 return; | 62 return; |
| 79 } | 63 } |
| 80 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 64 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 81 if (bSetting) { | 65 if (bSetting) { |
| 82 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc, | 66 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 194 } |
| 211 if (bSetting) { | 195 if (bSetting) { |
| 212 ThrowException(XFA_IDS_UNABLE_SET_VERSION); | 196 ThrowException(XFA_IDS_UNABLE_SET_VERSION); |
| 213 return; | 197 return; |
| 214 } | 198 } |
| 215 CFX_WideString wsVersion; | 199 CFX_WideString wsVersion; |
| 216 pNotify->GetAppProvider()->GetVersion(wsVersion); | 200 pNotify->GetAppProvider()->GetVersion(wsVersion); |
| 217 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); | 201 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); |
| 218 } | 202 } |
| 219 | 203 |
| 220 void CScript_HostPseudoModel::FoxitVersion(CFXJSE_Value* pValue, | |
| 221 FX_BOOL bSetting, | |
| 222 XFA_ATTRIBUTE eAttribute) { | |
| 223 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | |
| 224 if (!pNotify) { | |
| 225 return; | |
| 226 } | |
| 227 if (bSetting) { | |
| 228 ThrowException(XFA_IDS_UNABLE_SET_VERSION); | |
| 229 return; | |
| 230 } | |
| 231 CFX_WideString wsVersion; | |
| 232 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); | |
| 233 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); | |
| 234 } | |
| 235 | |
| 236 void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, | 204 void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, |
| 237 FX_BOOL bSetting, | 205 FX_BOOL bSetting, |
| 238 XFA_ATTRIBUTE eAttribute) { | 206 XFA_ATTRIBUTE eAttribute) { |
| 239 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 207 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
| 240 if (!pNotify) { | 208 if (!pNotify) { |
| 241 return; | 209 return; |
| 242 } | 210 } |
| 243 if (bSetting) { | 211 if (bSetting) { |
| 244 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 212 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 245 return; | 213 return; |
| 246 } | 214 } |
| 247 CFX_WideString wsAppName; | 215 CFX_WideString wsAppName; |
| 248 pNotify->GetAppProvider()->GetAppName(wsAppName); | 216 pNotify->GetAppProvider()->GetAppName(wsAppName); |
| 249 pValue->SetString(FX_UTF8Encode(wsAppName).AsStringC()); | 217 pValue->SetString(FX_UTF8Encode(wsAppName).AsStringC()); |
| 250 } | 218 } |
| 251 | 219 |
| 252 void CScript_HostPseudoModel::FoxitName(CFXJSE_Value* pValue, | |
| 253 FX_BOOL bSetting, | |
| 254 XFA_ATTRIBUTE eAttribute) { | |
| 255 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | |
| 256 if (!pNotify) { | |
| 257 return; | |
| 258 } | |
| 259 if (bSetting) { | |
| 260 ThrowException(XFA_IDS_INVAlID_PROP_SET); | |
| 261 return; | |
| 262 } | |
| 263 CFX_WideString wsFoxitAppName; | |
| 264 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); | |
| 265 pValue->SetString(FX_UTF8Encode(wsFoxitAppName).AsStringC()); | |
| 266 } | |
| 267 void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { | 220 void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { |
| 268 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 221 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 269 return; | 222 return; |
| 270 } | 223 } |
| 271 int32_t iLength = pArguments->GetLength(); | 224 int32_t iLength = pArguments->GetLength(); |
| 272 if (iLength != 1) { | 225 if (iLength != 1) { |
| 273 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); | 226 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); |
| 274 return; | 227 return; |
| 275 } | 228 } |
| 276 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 229 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { | 705 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { |
| 753 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 706 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
| 754 if (!pNotify) { | 707 if (!pNotify) { |
| 755 return; | 708 return; |
| 756 } | 709 } |
| 757 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 710 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 758 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 711 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 759 if (pValue) | 712 if (pValue) |
| 760 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 713 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
| 761 } | 714 } |
| OLD | NEW |