| 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 "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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass)); | 25 return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) | 30 CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) |
| 31 : CXFA_Object(pDocument, | 31 : CXFA_Object(pDocument, |
| 32 XFA_ObjectType::Object, | 32 XFA_ObjectType::Object, |
| 33 XFA_Element::HostPseudoModel) {} | 33 XFA_Element::HostPseudoModel) {} |
| 34 CScript_HostPseudoModel::~CScript_HostPseudoModel() {} | 34 CScript_HostPseudoModel::~CScript_HostPseudoModel() {} |
| 35 void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( | 35 void CScript_HostPseudoModel::LoadString(CFXJSE_Value* pValue, |
| 36 CFXJSE_Value* pValue, | 36 CXFA_FFNotify* pNotify, |
| 37 CXFA_FFNotify* pNotify, | 37 uint32_t dwFlag) { |
| 38 uint32_t dwFlag) { | |
| 39 CFX_WideString wsValue; | 38 CFX_WideString wsValue; |
| 40 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); | 39 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); |
| 41 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 40 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
| 42 } | 41 } |
| 43 void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( | 42 void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, |
| 44 CFXJSE_Value* pValue, | 43 FX_BOOL bSetting, |
| 45 FX_BOOL bSetting, | 44 XFA_ATTRIBUTE eAttribute) { |
| 46 XFA_ATTRIBUTE eAttribute) { | |
| 47 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 45 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 48 if (!pNotify) { | 46 if (!pNotify) { |
| 49 return; | 47 return; |
| 50 } | 48 } |
| 51 if (bSetting) { | 49 if (bSetting) { |
| 52 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 50 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 53 return; | 51 return; |
| 54 } | 52 } |
| 55 CFX_WideString wsAppType; | 53 CFX_WideString wsAppType; |
| 56 pNotify->GetAppProvider()->GetAppType(wsAppType); | 54 pNotify->GetAppProvider()->GetAppType(wsAppType); |
| 57 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); | 55 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); |
| 58 } | 56 } |
| 59 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( | 57 void CScript_HostPseudoModel::FoxitAppType(CFXJSE_Value* pValue, |
| 60 CFXJSE_Value* pValue, | 58 FX_BOOL bSetting, |
| 61 FX_BOOL bSetting, | 59 XFA_ATTRIBUTE eAttribute) { |
| 62 XFA_ATTRIBUTE eAttribute) { | |
| 63 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 60 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 64 if (!pNotify) { | 61 if (!pNotify) { |
| 65 return; | 62 return; |
| 66 } | 63 } |
| 67 if (bSetting) { | 64 if (bSetting) { |
| 68 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 65 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 69 return; | 66 return; |
| 70 } | 67 } |
| 71 CFX_WideString wsAppType; | 68 CFX_WideString wsAppType; |
| 72 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); | 69 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); |
| 73 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); | 70 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); |
| 74 } | 71 } |
| 75 void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( | 72 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, |
| 76 CFXJSE_Value* pValue, | 73 FX_BOOL bSetting, |
| 77 FX_BOOL bSetting, | 74 XFA_ATTRIBUTE eAttribute) { |
| 78 XFA_ATTRIBUTE eAttribute) { | |
| 79 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 75 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 80 if (!pNotify) { | 76 if (!pNotify) { |
| 81 return; | 77 return; |
| 82 } | 78 } |
| 83 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 79 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 84 if (bSetting) { | 80 if (bSetting) { |
| 85 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc, | 81 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc, |
| 86 pValue->ToBoolean()); | 82 pValue->ToBoolean()); |
| 87 return; | 83 return; |
| 88 } | 84 } |
| 89 pValue->SetBoolean(pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc)); | 85 pValue->SetBoolean(pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc)); |
| 90 } | 86 } |
| 91 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentPage( | 87 void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue, |
| 92 CFXJSE_Value* pValue, | 88 FX_BOOL bSetting, |
| 93 FX_BOOL bSetting, | 89 XFA_ATTRIBUTE eAttribute) { |
| 94 XFA_ATTRIBUTE eAttribute) { | |
| 95 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 90 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 96 if (!pNotify) { | 91 if (!pNotify) { |
| 97 return; | 92 return; |
| 98 } | 93 } |
| 99 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 94 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 100 if (bSetting) { | 95 if (bSetting) { |
| 101 pNotify->GetDocProvider()->SetCurrentPage(hDoc, pValue->ToInteger()); | 96 pNotify->GetDocProvider()->SetCurrentPage(hDoc, pValue->ToInteger()); |
| 102 return; | 97 return; |
| 103 } | 98 } |
| 104 pValue->SetInteger(pNotify->GetDocProvider()->GetCurrentPage(hDoc)); | 99 pValue->SetInteger(pNotify->GetDocProvider()->GetCurrentPage(hDoc)); |
| 105 } | 100 } |
| 106 void CScript_HostPseudoModel::Script_HostPseudoModel_Language( | 101 void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, |
| 107 CFXJSE_Value* pValue, | 102 FX_BOOL bSetting, |
| 108 FX_BOOL bSetting, | 103 XFA_ATTRIBUTE eAttribute) { |
| 109 XFA_ATTRIBUTE eAttribute) { | |
| 110 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 104 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 111 if (!pNotify) { | 105 if (!pNotify) { |
| 112 return; | 106 return; |
| 113 } | 107 } |
| 114 if (bSetting) { | 108 if (bSetting) { |
| 115 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); | 109 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); |
| 116 return; | 110 return; |
| 117 } | 111 } |
| 118 CFX_WideString wsLanguage; | 112 CFX_WideString wsLanguage; |
| 119 pNotify->GetAppProvider()->GetLanguage(wsLanguage); | 113 pNotify->GetAppProvider()->GetLanguage(wsLanguage); |
| 120 pValue->SetString(FX_UTF8Encode(wsLanguage).AsStringC()); | 114 pValue->SetString(FX_UTF8Encode(wsLanguage).AsStringC()); |
| 121 } | 115 } |
| 122 void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( | 116 void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, |
| 123 CFXJSE_Value* pValue, | 117 FX_BOOL bSetting, |
| 124 FX_BOOL bSetting, | 118 XFA_ATTRIBUTE eAttribute) { |
| 125 XFA_ATTRIBUTE eAttribute) { | |
| 126 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 119 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 127 if (!pNotify) { | 120 if (!pNotify) { |
| 128 return; | 121 return; |
| 129 } | 122 } |
| 130 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 123 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 131 if (bSetting) { | 124 if (bSetting) { |
| 132 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); | 125 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); |
| 133 return; | 126 return; |
| 134 } | 127 } |
| 135 pValue->SetInteger(pNotify->GetDocProvider()->CountPages(hDoc)); | 128 pValue->SetInteger(pNotify->GetDocProvider()->CountPages(hDoc)); |
| 136 } | 129 } |
| 137 void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( | 130 void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, |
| 138 CFXJSE_Value* pValue, | 131 FX_BOOL bSetting, |
| 139 FX_BOOL bSetting, | 132 XFA_ATTRIBUTE eAttribute) { |
| 140 XFA_ATTRIBUTE eAttribute) { | |
| 141 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 133 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 142 if (!pNotify) { | 134 if (!pNotify) { |
| 143 return; | 135 return; |
| 144 } | 136 } |
| 145 if (bSetting) { | 137 if (bSetting) { |
| 146 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); | 138 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); |
| 147 return; | 139 return; |
| 148 } | 140 } |
| 149 CFX_WideString wsPlatform; | 141 CFX_WideString wsPlatform; |
| 150 pNotify->GetAppProvider()->GetPlatform(wsPlatform); | 142 pNotify->GetAppProvider()->GetPlatform(wsPlatform); |
| 151 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC()); | 143 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC()); |
| 152 } | 144 } |
| 153 void CScript_HostPseudoModel::Script_HostPseudoModel_Title( | 145 void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, |
| 154 CFXJSE_Value* pValue, | 146 FX_BOOL bSetting, |
| 155 FX_BOOL bSetting, | 147 XFA_ATTRIBUTE eAttribute) { |
| 156 XFA_ATTRIBUTE eAttribute) { | |
| 157 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 148 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 158 return; | 149 return; |
| 159 } | 150 } |
| 160 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 151 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 161 if (!pNotify) { | 152 if (!pNotify) { |
| 162 return; | 153 return; |
| 163 } | 154 } |
| 164 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 155 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 165 if (bSetting) { | 156 if (bSetting) { |
| 166 pNotify->GetDocProvider()->SetTitle(hDoc, pValue->ToWideString()); | 157 pNotify->GetDocProvider()->SetTitle(hDoc, pValue->ToWideString()); |
| 167 return; | 158 return; |
| 168 } | 159 } |
| 169 CFX_WideString wsTitle; | 160 CFX_WideString wsTitle; |
| 170 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); | 161 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); |
| 171 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); | 162 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); |
| 172 } | 163 } |
| 173 void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( | 164 void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, |
| 174 CFXJSE_Value* pValue, | 165 FX_BOOL bSetting, |
| 175 FX_BOOL bSetting, | 166 XFA_ATTRIBUTE eAttribute) { |
| 176 XFA_ATTRIBUTE eAttribute) { | |
| 177 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 167 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 178 if (!pNotify) { | 168 if (!pNotify) { |
| 179 return; | 169 return; |
| 180 } | 170 } |
| 181 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 171 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 182 if (bSetting) { | 172 if (bSetting) { |
| 183 pNotify->GetDocProvider()->SetValidationsEnabled(hDoc, pValue->ToBoolean()); | 173 pNotify->GetDocProvider()->SetValidationsEnabled(hDoc, pValue->ToBoolean()); |
| 184 return; | 174 return; |
| 185 } | 175 } |
| 186 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); | 176 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); |
| 187 pValue->SetBoolean(bEnabled); | 177 pValue->SetBoolean(bEnabled); |
| 188 } | 178 } |
| 189 void CScript_HostPseudoModel::Script_HostPseudoModel_Variation( | 179 void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, |
| 190 CFXJSE_Value* pValue, | 180 FX_BOOL bSetting, |
| 191 FX_BOOL bSetting, | 181 XFA_ATTRIBUTE eAttribute) { |
| 192 XFA_ATTRIBUTE eAttribute) { | |
| 193 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 182 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 194 return; | 183 return; |
| 195 } | 184 } |
| 196 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 185 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 197 if (!pNotify) { | 186 if (!pNotify) { |
| 198 return; | 187 return; |
| 199 } | 188 } |
| 200 if (bSetting) { | 189 if (bSetting) { |
| 201 ThrowException(XFA_IDS_UNABLE_SET_VARIATION); | 190 ThrowException(XFA_IDS_UNABLE_SET_VARIATION); |
| 202 return; | 191 return; |
| 203 } | 192 } |
| 204 CFX_WideString wsVariation; | 193 CFX_WideString wsVariation; |
| 205 pNotify->GetAppProvider()->GetVariation(wsVariation); | 194 pNotify->GetAppProvider()->GetVariation(wsVariation); |
| 206 pValue->SetString(FX_UTF8Encode(wsVariation).AsStringC()); | 195 pValue->SetString(FX_UTF8Encode(wsVariation).AsStringC()); |
| 207 } | 196 } |
| 208 void CScript_HostPseudoModel::Script_HostPseudoModel_Version( | 197 void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, |
| 209 CFXJSE_Value* pValue, | 198 FX_BOOL bSetting, |
| 210 FX_BOOL bSetting, | 199 XFA_ATTRIBUTE eAttribute) { |
| 211 XFA_ATTRIBUTE eAttribute) { | |
| 212 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 200 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 213 if (!pNotify) { | 201 if (!pNotify) { |
| 214 return; | 202 return; |
| 215 } | 203 } |
| 216 if (bSetting) { | 204 if (bSetting) { |
| 217 ThrowException(XFA_IDS_UNABLE_SET_VERSION); | 205 ThrowException(XFA_IDS_UNABLE_SET_VERSION); |
| 218 return; | 206 return; |
| 219 } | 207 } |
| 220 CFX_WideString wsVersion; | 208 CFX_WideString wsVersion; |
| 221 pNotify->GetAppProvider()->GetVersion(wsVersion); | 209 pNotify->GetAppProvider()->GetVersion(wsVersion); |
| 222 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); | 210 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); |
| 223 } | 211 } |
| 224 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( | 212 void CScript_HostPseudoModel::FoxitVersion(CFXJSE_Value* pValue, |
| 225 CFXJSE_Value* pValue, | 213 FX_BOOL bSetting, |
| 226 FX_BOOL bSetting, | 214 XFA_ATTRIBUTE eAttribute) { |
| 227 XFA_ATTRIBUTE eAttribute) { | |
| 228 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 215 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 229 if (!pNotify) { | 216 if (!pNotify) { |
| 230 return; | 217 return; |
| 231 } | 218 } |
| 232 if (bSetting) { | 219 if (bSetting) { |
| 233 ThrowException(XFA_IDS_UNABLE_SET_VERSION); | 220 ThrowException(XFA_IDS_UNABLE_SET_VERSION); |
| 234 return; | 221 return; |
| 235 } | 222 } |
| 236 CFX_WideString wsVersion; | 223 CFX_WideString wsVersion; |
| 237 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); | 224 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); |
| 238 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); | 225 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); |
| 239 } | 226 } |
| 240 void CScript_HostPseudoModel::Script_HostPseudoModel_Name( | 227 void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, |
| 241 CFXJSE_Value* pValue, | 228 FX_BOOL bSetting, |
| 242 FX_BOOL bSetting, | 229 XFA_ATTRIBUTE eAttribute) { |
| 243 XFA_ATTRIBUTE eAttribute) { | |
| 244 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 230 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 245 if (!pNotify) { | 231 if (!pNotify) { |
| 246 return; | 232 return; |
| 247 } | 233 } |
| 248 if (bSetting) { | 234 if (bSetting) { |
| 249 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 235 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 250 return; | 236 return; |
| 251 } | 237 } |
| 252 CFX_WideString wsAppName; | 238 CFX_WideString wsAppName; |
| 253 pNotify->GetAppProvider()->GetAppName(wsAppName); | 239 pNotify->GetAppProvider()->GetAppName(wsAppName); |
| 254 pValue->SetString(FX_UTF8Encode(wsAppName).AsStringC()); | 240 pValue->SetString(FX_UTF8Encode(wsAppName).AsStringC()); |
| 255 } | 241 } |
| 256 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( | 242 void CScript_HostPseudoModel::FoxitName(CFXJSE_Value* pValue, |
| 257 CFXJSE_Value* pValue, | 243 FX_BOOL bSetting, |
| 258 FX_BOOL bSetting, | 244 XFA_ATTRIBUTE eAttribute) { |
| 259 XFA_ATTRIBUTE eAttribute) { | |
| 260 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 245 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 261 if (!pNotify) { | 246 if (!pNotify) { |
| 262 return; | 247 return; |
| 263 } | 248 } |
| 264 if (bSetting) { | 249 if (bSetting) { |
| 265 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 250 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
| 266 return; | 251 return; |
| 267 } | 252 } |
| 268 CFX_WideString wsFoxitAppName; | 253 CFX_WideString wsFoxitAppName; |
| 269 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); | 254 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); |
| 270 pValue->SetString(FX_UTF8Encode(wsFoxitAppName).AsStringC()); | 255 pValue->SetString(FX_UTF8Encode(wsFoxitAppName).AsStringC()); |
| 271 } | 256 } |
| 272 void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( | 257 void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { |
| 273 CFXJSE_Arguments* pArguments) { | |
| 274 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 258 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 275 return; | 259 return; |
| 276 } | 260 } |
| 277 int32_t iLength = pArguments->GetLength(); | 261 int32_t iLength = pArguments->GetLength(); |
| 278 if (iLength != 1) { | 262 if (iLength != 1) { |
| 279 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); | 263 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); |
| 280 return; | 264 return; |
| 281 } | 265 } |
| 282 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 266 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 283 if (!pNotify) { | 267 if (!pNotify) { |
| 284 return; | 268 return; |
| 285 } | 269 } |
| 286 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 270 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 287 CFX_WideString wsURL; | 271 CFX_WideString wsURL; |
| 288 if (iLength >= 1) { | 272 if (iLength >= 1) { |
| 289 CFX_ByteString bsURL = pArguments->GetUTF8String(0); | 273 CFX_ByteString bsURL = pArguments->GetUTF8String(0); |
| 290 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); | 274 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); |
| 291 } | 275 } |
| 292 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); | 276 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); |
| 293 } | 277 } |
| 294 void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( | 278 void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { |
| 295 CFXJSE_Arguments* pArguments) { | |
| 296 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 279 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 297 return; | 280 return; |
| 298 } | 281 } |
| 299 int32_t iLength = pArguments->GetLength(); | 282 int32_t iLength = pArguments->GetLength(); |
| 300 if (iLength != 1) { | 283 if (iLength != 1) { |
| 301 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); | 284 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); |
| 302 return; | 285 return; |
| 303 } | 286 } |
| 304 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 287 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 305 if (!pNotify) { | 288 if (!pNotify) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 335 return; | 318 return; |
| 336 } | 319 } |
| 337 CXFA_FFWidget* hWidget = | 320 CXFA_FFWidget* hWidget = |
| 338 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); | 321 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); |
| 339 if (!hWidget) { | 322 if (!hWidget) { |
| 340 return; | 323 return; |
| 341 } | 324 } |
| 342 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); | 325 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); |
| 343 pNotify->OpenDropDownList(hWidget); | 326 pNotify->OpenDropDownList(hWidget); |
| 344 } | 327 } |
| 345 void CScript_HostPseudoModel::Script_HostPseudoModel_Response( | 328 void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { |
| 346 CFXJSE_Arguments* pArguments) { | |
| 347 int32_t iLength = pArguments->GetLength(); | 329 int32_t iLength = pArguments->GetLength(); |
| 348 if (iLength < 1 || iLength > 4) { | 330 if (iLength < 1 || iLength > 4) { |
| 349 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); | 331 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); |
| 350 return; | 332 return; |
| 351 } | 333 } |
| 352 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 334 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 353 if (!pNotify) { | 335 if (!pNotify) { |
| 354 return; | 336 return; |
| 355 } | 337 } |
| 356 CFX_WideString wsQuestion; | 338 CFX_WideString wsQuestion; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 371 } | 353 } |
| 372 if (iLength >= 4) { | 354 if (iLength >= 4) { |
| 373 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; | 355 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; |
| 374 } | 356 } |
| 375 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( | 357 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( |
| 376 wsQuestion, wsTitle, wsDefaultAnswer, bMark); | 358 wsQuestion, wsTitle, wsDefaultAnswer, bMark); |
| 377 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 359 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 378 if (pValue) | 360 if (pValue) |
| 379 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); | 361 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); |
| 380 } | 362 } |
| 381 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( | 363 void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { |
| 382 CFXJSE_Arguments* pArguments) { | |
| 383 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 364 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 384 if (!pNotify) { | 365 if (!pNotify) { |
| 385 return; | 366 return; |
| 386 } | 367 } |
| 387 int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); | 368 int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); |
| 388 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 369 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 389 if (pValue) | 370 if (pValue) |
| 390 pValue->SetInteger(iCur); | 371 pValue->SetInteger(iCur); |
| 391 } | 372 } |
| 392 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, | 373 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 406 if (wCur == ',') { | 387 if (wCur == ',') { |
| 407 break; | 388 break; |
| 408 } | 389 } |
| 409 pBuf[nCount++] = wCur; | 390 pBuf[nCount++] = wCur; |
| 410 } | 391 } |
| 411 wsFilter.ReleaseBuffer(nCount); | 392 wsFilter.ReleaseBuffer(nCount); |
| 412 wsFilter.TrimLeft(); | 393 wsFilter.TrimLeft(); |
| 413 wsFilter.TrimRight(); | 394 wsFilter.TrimRight(); |
| 414 return nStart; | 395 return nStart; |
| 415 } | 396 } |
| 416 void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( | 397 void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { |
| 417 CFXJSE_Arguments* pArguments) { | |
| 418 int32_t iLength = pArguments->GetLength(); | 398 int32_t iLength = pArguments->GetLength(); |
| 419 if (iLength < 0 || iLength > 1) { | 399 if (iLength < 0 || iLength > 1) { |
| 420 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); | 400 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); |
| 421 return; | 401 return; |
| 422 } | 402 } |
| 423 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 403 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 424 if (!pNotify) { | 404 if (!pNotify) { |
| 425 return; | 405 return; |
| 426 } | 406 } |
| 427 CFX_WideString wsExpression; | 407 CFX_WideString wsExpression; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 455 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { | 435 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { |
| 456 continue; | 436 continue; |
| 457 } | 437 } |
| 458 pNode = resoveNodeRS.nodes[0]->AsNode(); | 438 pNode = resoveNodeRS.nodes[0]->AsNode(); |
| 459 pNotify->ResetData(pNode->GetWidgetData()); | 439 pNotify->ResetData(pNode->GetWidgetData()); |
| 460 } | 440 } |
| 461 if (!pNode) { | 441 if (!pNode) { |
| 462 pNotify->ResetData(); | 442 pNotify->ResetData(); |
| 463 } | 443 } |
| 464 } | 444 } |
| 465 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( | 445 void CScript_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) { |
| 466 CFXJSE_Arguments* pArguments) { | |
| 467 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 446 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 468 return; | 447 return; |
| 469 } | 448 } |
| 470 int32_t iLength = pArguments->GetLength(); | 449 int32_t iLength = pArguments->GetLength(); |
| 471 if (iLength < 0 || iLength > 1) { | 450 if (iLength < 0 || iLength > 1) { |
| 472 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); | 451 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); |
| 473 return; | 452 return; |
| 474 } | 453 } |
| 475 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 454 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 476 if (!pNotify) { | 455 if (!pNotify) { |
| 477 return; | 456 return; |
| 478 } | 457 } |
| 479 uint32_t dwType = 4; | 458 uint32_t dwType = 4; |
| 480 if (iLength >= 1) { | 459 if (iLength >= 1) { |
| 481 dwType = pArguments->GetInt32(0); | 460 dwType = pArguments->GetInt32(0); |
| 482 } | 461 } |
| 483 pNotify->GetAppProvider()->Beep(dwType); | 462 pNotify->GetAppProvider()->Beep(dwType); |
| 484 } | 463 } |
| 485 void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( | 464 void CScript_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) { |
| 486 CFXJSE_Arguments* pArguments) { | |
| 487 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 465 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 488 return; | 466 return; |
| 489 } | 467 } |
| 490 int32_t iLength = pArguments->GetLength(); | 468 int32_t iLength = pArguments->GetLength(); |
| 491 if (iLength != 1) { | 469 if (iLength != 1) { |
| 492 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); | 470 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); |
| 493 return; | 471 return; |
| 494 } | 472 } |
| 495 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 473 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 496 if (!pNotify) { | 474 if (!pNotify) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 516 int32_t iRet = pScriptContext->ResolveObjects( | 494 int32_t iRet = pScriptContext->ResolveObjects( |
| 517 pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag); | 495 pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag); |
| 518 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) | 496 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) |
| 519 return; | 497 return; |
| 520 | 498 |
| 521 pNode = resoveNodeRS.nodes[0]->AsNode(); | 499 pNode = resoveNodeRS.nodes[0]->AsNode(); |
| 522 } | 500 } |
| 523 } | 501 } |
| 524 pNotify->SetFocusWidgetNode(pNode); | 502 pNotify->SetFocusWidgetNode(pNode); |
| 525 } | 503 } |
| 526 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( | 504 void CScript_HostPseudoModel::GetFocus(CFXJSE_Arguments* pArguments) { |
| 527 CFXJSE_Arguments* pArguments) { | |
| 528 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 505 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 529 if (!pNotify) { | 506 if (!pNotify) { |
| 530 return; | 507 return; |
| 531 } | 508 } |
| 532 CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); | 509 CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); |
| 533 if (!pNode) { | 510 if (!pNode) { |
| 534 return; | 511 return; |
| 535 } | 512 } |
| 536 pArguments->GetReturnValue()->Assign( | 513 pArguments->GetReturnValue()->Assign( |
| 537 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 514 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
| 538 } | 515 } |
| 539 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( | 516 void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { |
| 540 CFXJSE_Arguments* pArguments) { | |
| 541 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 517 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 542 return; | 518 return; |
| 543 } | 519 } |
| 544 int32_t iLength = pArguments->GetLength(); | 520 int32_t iLength = pArguments->GetLength(); |
| 545 if (iLength < 1 || iLength > 4) { | 521 if (iLength < 1 || iLength > 4) { |
| 546 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); | 522 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); |
| 547 return; | 523 return; |
| 548 } | 524 } |
| 549 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 525 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 550 if (!pNotify) { | 526 if (!pNotify) { |
| 551 return; | 527 return; |
| 552 } | 528 } |
| 553 CFX_WideString wsMessage; | 529 CFX_WideString wsMessage; |
| 554 CFX_WideString bsTitle; | 530 CFX_WideString bsTitle; |
| 555 uint32_t dwMessageType = XFA_MBICON_Error; | 531 uint32_t dwMessageType = XFA_MBICON_Error; |
| 556 uint32_t dwButtonType = XFA_MB_OK; | 532 uint32_t dwButtonType = XFA_MB_OK; |
| 557 if (iLength >= 1) { | 533 if (iLength >= 1) { |
| 558 if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 0, wsMessage)) { | 534 if (!ValidateArgsForMsg(pArguments, 0, wsMessage)) { |
| 559 return; | 535 return; |
| 560 } | 536 } |
| 561 } | 537 } |
| 562 if (iLength >= 2) { | 538 if (iLength >= 2) { |
| 563 if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 1, bsTitle)) { | 539 if (!ValidateArgsForMsg(pArguments, 1, bsTitle)) { |
| 564 return; | 540 return; |
| 565 } | 541 } |
| 566 } | 542 } |
| 567 if (iLength >= 3) { | 543 if (iLength >= 3) { |
| 568 dwMessageType = pArguments->GetInt32(2); | 544 dwMessageType = pArguments->GetInt32(2); |
| 569 if (dwMessageType > XFA_MBICON_Status) { | 545 if (dwMessageType > XFA_MBICON_Status) { |
| 570 dwMessageType = XFA_MBICON_Error; | 546 dwMessageType = XFA_MBICON_Error; |
| 571 } | 547 } |
| 572 } | 548 } |
| 573 if (iLength >= 4) { | 549 if (iLength >= 4) { |
| 574 dwButtonType = pArguments->GetInt32(3); | 550 dwButtonType = pArguments->GetInt32(3); |
| 575 if (dwButtonType > XFA_MB_YesNoCancel) { | 551 if (dwButtonType > XFA_MB_YesNoCancel) { |
| 576 dwButtonType = XFA_MB_OK; | 552 dwButtonType = XFA_MB_OK; |
| 577 } | 553 } |
| 578 } | 554 } |
| 579 int32_t iValue = pNotify->GetAppProvider()->MsgBox( | 555 int32_t iValue = pNotify->GetAppProvider()->MsgBox( |
| 580 wsMessage, bsTitle, dwMessageType, dwButtonType); | 556 wsMessage, bsTitle, dwMessageType, dwButtonType); |
| 581 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 557 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 582 if (pValue) | 558 if (pValue) |
| 583 pValue->SetInteger(iValue); | 559 pValue->SetInteger(iValue); |
| 584 } | 560 } |
| 585 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( | 561 FX_BOOL CScript_HostPseudoModel::ValidateArgsForMsg( |
| 586 CFXJSE_Arguments* pArguments, | 562 CFXJSE_Arguments* pArguments, |
| 587 int32_t iArgIndex, | 563 int32_t iArgIndex, |
| 588 CFX_WideString& wsValue) { | 564 CFX_WideString& wsValue) { |
| 589 if (!pArguments || iArgIndex < 0) { | 565 if (!pArguments || iArgIndex < 0) { |
| 590 return FALSE; | 566 return FALSE; |
| 591 } | 567 } |
| 592 FX_BOOL bIsJsType = FALSE; | 568 FX_BOOL bIsJsType = FALSE; |
| 593 if (m_pDocument->GetScriptContext()->GetType() == | 569 if (m_pDocument->GetScriptContext()->GetType() == |
| 594 XFA_SCRIPTLANGTYPE_Javascript) { | 570 XFA_SCRIPTLANGTYPE_Javascript) { |
| 595 bIsJsType = TRUE; | 571 bIsJsType = TRUE; |
| 596 } | 572 } |
| 597 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 573 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
| 598 if (!pValueArg->IsString() && bIsJsType) { | 574 if (!pValueArg->IsString() && bIsJsType) { |
| 599 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 575 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 600 return FALSE; | 576 return FALSE; |
| 601 } | 577 } |
| 602 if (pValueArg->IsNull()) { | 578 if (pValueArg->IsNull()) { |
| 603 wsValue = FX_WSTRC(L""); | 579 wsValue = FX_WSTRC(L""); |
| 604 } else { | 580 } else { |
| 605 wsValue = pValueArg->ToWideString(); | 581 wsValue = pValueArg->ToWideString(); |
| 606 } | 582 } |
| 607 return TRUE; | 583 return TRUE; |
| 608 } | 584 } |
| 609 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( | 585 void CScript_HostPseudoModel::DocumentCountInBatch( |
| 610 CFXJSE_Arguments* pArguments) { | 586 CFXJSE_Arguments* pArguments) { |
| 611 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 587 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 612 if (!pNotify) { | 588 if (!pNotify) { |
| 613 return; | 589 return; |
| 614 } | 590 } |
| 615 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); | 591 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); |
| 616 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 592 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 617 if (pValue) | 593 if (pValue) |
| 618 pValue->SetInteger(iValue); | 594 pValue->SetInteger(iValue); |
| 619 } | 595 } |
| 620 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( | 596 void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { |
| 621 CFXJSE_Arguments* pArguments) { | |
| 622 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 597 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 623 return; | 598 return; |
| 624 } | 599 } |
| 625 int32_t iLength = pArguments->GetLength(); | 600 int32_t iLength = pArguments->GetLength(); |
| 626 if (iLength != 8) { | 601 if (iLength != 8) { |
| 627 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); | 602 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); |
| 628 return; | 603 return; |
| 629 } | 604 } |
| 630 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 605 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 631 if (!pNotify) { | 606 if (!pNotify) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 654 } |
| 680 FX_BOOL bPrintAnnot = TRUE; | 655 FX_BOOL bPrintAnnot = TRUE; |
| 681 if (iLength >= 8) { | 656 if (iLength >= 8) { |
| 682 bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; | 657 bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; |
| 683 } | 658 } |
| 684 if (bPrintAnnot) { | 659 if (bPrintAnnot) { |
| 685 dwOptions |= XFA_PRINTOPT_PrintAnnot; | 660 dwOptions |= XFA_PRINTOPT_PrintAnnot; |
| 686 } | 661 } |
| 687 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); | 662 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); |
| 688 } | 663 } |
| 689 void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( | 664 void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { |
| 690 CFXJSE_Arguments* pArguments) { | |
| 691 int32_t iLength = pArguments->GetLength(); | 665 int32_t iLength = pArguments->GetLength(); |
| 692 if (iLength < 0 || iLength > 1) { | 666 if (iLength < 0 || iLength > 1) { |
| 693 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); | 667 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); |
| 694 return; | 668 return; |
| 695 } | 669 } |
| 696 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 670 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 697 if (!pNotify) { | 671 if (!pNotify) { |
| 698 return; | 672 return; |
| 699 } | 673 } |
| 700 CFX_WideString wsFilePath; | 674 CFX_WideString wsFilePath; |
| 701 if (iLength > 0) { | 675 if (iLength > 0) { |
| 702 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 676 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 703 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 677 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 704 } | 678 } |
| 705 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 679 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 706 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); | 680 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); |
| 707 } | 681 } |
| 708 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( | 682 void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { |
| 709 CFXJSE_Arguments* pArguments) { | |
| 710 int32_t iLength = pArguments->GetLength(); | 683 int32_t iLength = pArguments->GetLength(); |
| 711 if (iLength < 0 || iLength > 2) { | 684 if (iLength < 0 || iLength > 2) { |
| 712 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); | 685 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); |
| 713 return; | 686 return; |
| 714 } | 687 } |
| 715 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 688 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 716 if (!pNotify) { | 689 if (!pNotify) { |
| 717 return; | 690 return; |
| 718 } | 691 } |
| 719 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 692 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 720 CFX_WideString wsFilePath; | 693 CFX_WideString wsFilePath; |
| 721 FX_BOOL bXDP = TRUE; | 694 FX_BOOL bXDP = TRUE; |
| 722 if (iLength >= 1) { | 695 if (iLength >= 1) { |
| 723 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 696 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 724 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 697 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 725 } | 698 } |
| 726 if (iLength >= 2) { | 699 if (iLength >= 2) { |
| 727 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | 700 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; |
| 728 } | 701 } |
| 729 pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); | 702 pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); |
| 730 } | 703 } |
| 731 void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp( | 704 void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) { |
| 732 CFXJSE_Arguments* pArguments) { | |
| 733 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 705 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 734 if (!pNotify) { | 706 if (!pNotify) { |
| 735 return; | 707 return; |
| 736 } | 708 } |
| 737 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 709 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 738 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); | 710 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); |
| 739 int32_t nNewPage = 0; | 711 int32_t nNewPage = 0; |
| 740 if (nCurPage <= 1) { | 712 if (nCurPage <= 1) { |
| 741 return; | 713 return; |
| 742 } | 714 } |
| 743 nNewPage = nCurPage - 1; | 715 nNewPage = nCurPage - 1; |
| 744 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); | 716 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); |
| 745 } | 717 } |
| 746 void CScript_HostPseudoModel::Script_HostPseudoModel_PageDown( | 718 void CScript_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) { |
| 747 CFXJSE_Arguments* pArguments) { | |
| 748 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 719 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 749 if (!pNotify) { | 720 if (!pNotify) { |
| 750 return; | 721 return; |
| 751 } | 722 } |
| 752 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 723 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 753 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); | 724 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); |
| 754 int32_t nPageCount = pNotify->GetDocProvider()->CountPages(hDoc); | 725 int32_t nPageCount = pNotify->GetDocProvider()->CountPages(hDoc); |
| 755 if (!nPageCount || nCurPage == nPageCount) { | 726 if (!nPageCount || nCurPage == nPageCount) { |
| 756 return; | 727 return; |
| 757 } | 728 } |
| 758 int32_t nNewPage = 0; | 729 int32_t nNewPage = 0; |
| 759 if (nCurPage >= nPageCount) { | 730 if (nCurPage >= nPageCount) { |
| 760 nNewPage = nPageCount - 1; | 731 nNewPage = nPageCount - 1; |
| 761 } else { | 732 } else { |
| 762 nNewPage = nCurPage + 1; | 733 nNewPage = nCurPage + 1; |
| 763 } | 734 } |
| 764 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); | 735 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); |
| 765 } | 736 } |
| 766 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime( | 737 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { |
| 767 CFXJSE_Arguments* pArguments) { | |
| 768 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 738 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 769 if (!pNotify) { | 739 if (!pNotify) { |
| 770 return; | 740 return; |
| 771 } | 741 } |
| 772 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 742 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 773 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 743 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 774 if (pValue) | 744 if (pValue) |
| 775 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 745 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
| 776 } | 746 } |
| OLD | NEW |