| 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 "app.h" | 7 #include "app.h" |
| 8 | 8 |
| 9 #include "../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 11 #include "../../include/javascript/IJavaScript.h" | 11 #include "../../include/javascript/IJavaScript.h" |
| 12 #include "Document.h" | 12 #include "Document.h" |
| 13 #include "JS_Context.h" | 13 #include "JS_Context.h" |
| 14 #include "JS_Define.h" | 14 #include "JS_Define.h" |
| 15 #include "JS_EventHandler.h" | 15 #include "JS_EventHandler.h" |
| 16 #include "JS_Object.h" | 16 #include "JS_Object.h" |
| 17 #include "JS_Runtime.h" | 17 #include "JS_Runtime.h" |
| 18 #include "JS_Value.h" | 18 #include "JS_Value.h" |
| 19 #include "resource.h" | 19 #include "resource.h" |
| 20 | 20 |
| 21 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { | 21 static v8::Isolate* GetIsolate(IJS_Context* cc) { |
| 22 CJS_Context* pContext = (CJS_Context*)cc; | 22 CJS_Context* pContext = (CJS_Context*)cc; |
| 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 24 return pRuntime->GetIsolate(); | 24 return pRuntime->GetIsolate(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 27 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
| 28 END_JS_STATIC_CONST() | 28 END_JS_STATIC_CONST() |
| 29 | 29 |
| 30 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 30 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
| 31 END_JS_STATIC_PROP() | 31 END_JS_STATIC_PROP() |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 app::app(CJS_Object* pJSObject) | 102 app::app(CJS_Object* pJSObject) |
| 103 : CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {} | 103 : CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {} |
| 104 | 104 |
| 105 app::~app() { | 105 app::~app() { |
| 106 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) | 106 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) |
| 107 delete m_aTimer[i]; | 107 delete m_aTimer[i]; |
| 108 | 108 |
| 109 m_aTimer.RemoveAll(); | 109 m_aTimer.RemoveAll(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 FX_BOOL app::activeDocs(IFXJS_Context* cc, | 112 FX_BOOL app::activeDocs(IJS_Context* cc, |
| 113 CJS_PropValue& vp, | 113 CJS_PropValue& vp, |
| 114 CFX_WideString& sError) { | 114 CFX_WideString& sError) { |
| 115 if (!vp.IsGetting()) | 115 if (!vp.IsGetting()) |
| 116 return FALSE; | 116 return FALSE; |
| 117 | 117 |
| 118 CJS_Context* pContext = (CJS_Context*)cc; | 118 CJS_Context* pContext = (CJS_Context*)cc; |
| 119 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 119 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 120 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 120 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 121 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 121 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 122 CJS_Array aDocs(pRuntime->GetIsolate()); | 122 CJS_Array aDocs(pRuntime->GetIsolate()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 137 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); | 137 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); |
| 138 } | 138 } |
| 139 if (aDocs.GetLength() > 0) | 139 if (aDocs.GetLength() > 0) |
| 140 vp << aDocs; | 140 vp << aDocs; |
| 141 else | 141 else |
| 142 vp.SetNull(); | 142 vp.SetNull(); |
| 143 | 143 |
| 144 return TRUE; | 144 return TRUE; |
| 145 } | 145 } |
| 146 | 146 |
| 147 FX_BOOL app::calculate(IFXJS_Context* cc, | 147 FX_BOOL app::calculate(IJS_Context* cc, |
| 148 CJS_PropValue& vp, | 148 CJS_PropValue& vp, |
| 149 CFX_WideString& sError) { | 149 CFX_WideString& sError) { |
| 150 if (vp.IsSetting()) { | 150 if (vp.IsSetting()) { |
| 151 bool bVP; | 151 bool bVP; |
| 152 vp >> bVP; | 152 vp >> bVP; |
| 153 m_bCalculate = (FX_BOOL)bVP; | 153 m_bCalculate = (FX_BOOL)bVP; |
| 154 | 154 |
| 155 CJS_Context* pContext = (CJS_Context*)cc; | 155 CJS_Context* pContext = (CJS_Context*)cc; |
| 156 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 156 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 157 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 157 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 158 CJS_Array aDocs(pRuntime->GetIsolate()); | 158 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 159 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 159 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 160 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); | 160 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); |
| 161 } else { | 161 } else { |
| 162 vp << (bool)m_bCalculate; | 162 vp << (bool)m_bCalculate; |
| 163 } | 163 } |
| 164 return TRUE; | 164 return TRUE; |
| 165 } | 165 } |
| 166 | 166 |
| 167 FX_BOOL app::formsVersion(IFXJS_Context* cc, | 167 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 168 CJS_PropValue& vp, | 168 CJS_PropValue& vp, |
| 169 CFX_WideString& sError) { | 169 CFX_WideString& sError) { |
| 170 if (vp.IsGetting()) { | 170 if (vp.IsGetting()) { |
| 171 vp << JS_NUM_FORMSVERSION; | 171 vp << JS_NUM_FORMSVERSION; |
| 172 return TRUE; | 172 return TRUE; |
| 173 } | 173 } |
| 174 | 174 |
| 175 return FALSE; | 175 return FALSE; |
| 176 } | 176 } |
| 177 | 177 |
| 178 FX_BOOL app::viewerType(IFXJS_Context* cc, | 178 FX_BOOL app::viewerType(IJS_Context* cc, |
| 179 CJS_PropValue& vp, | 179 CJS_PropValue& vp, |
| 180 CFX_WideString& sError) { | 180 CFX_WideString& sError) { |
| 181 if (vp.IsGetting()) { | 181 if (vp.IsGetting()) { |
| 182 vp << JS_STR_VIEWERTYPE; | 182 vp << JS_STR_VIEWERTYPE; |
| 183 return TRUE; | 183 return TRUE; |
| 184 } | 184 } |
| 185 | 185 |
| 186 return FALSE; | 186 return FALSE; |
| 187 } | 187 } |
| 188 | 188 |
| 189 FX_BOOL app::viewerVariation(IFXJS_Context* cc, | 189 FX_BOOL app::viewerVariation(IJS_Context* cc, |
| 190 CJS_PropValue& vp, | 190 CJS_PropValue& vp, |
| 191 CFX_WideString& sError) { | 191 CFX_WideString& sError) { |
| 192 if (vp.IsGetting()) { | 192 if (vp.IsGetting()) { |
| 193 vp << JS_STR_VIEWERVARIATION; | 193 vp << JS_STR_VIEWERVARIATION; |
| 194 return TRUE; | 194 return TRUE; |
| 195 } | 195 } |
| 196 | 196 |
| 197 return FALSE; | 197 return FALSE; |
| 198 } | 198 } |
| 199 | 199 |
| 200 FX_BOOL app::viewerVersion(IFXJS_Context* cc, | 200 FX_BOOL app::viewerVersion(IJS_Context* cc, |
| 201 CJS_PropValue& vp, | 201 CJS_PropValue& vp, |
| 202 CFX_WideString& sError) { | 202 CFX_WideString& sError) { |
| 203 if (vp.IsGetting()) { | 203 if (vp.IsGetting()) { |
| 204 vp << JS_NUM_VIEWERVERSION; | 204 vp << JS_NUM_VIEWERVERSION; |
| 205 return TRUE; | 205 return TRUE; |
| 206 } | 206 } |
| 207 | 207 |
| 208 return FALSE; | 208 return FALSE; |
| 209 } | 209 } |
| 210 | 210 |
| 211 FX_BOOL app::platform(IFXJS_Context* cc, | 211 FX_BOOL app::platform(IJS_Context* cc, |
| 212 CJS_PropValue& vp, | 212 CJS_PropValue& vp, |
| 213 CFX_WideString& sError) { | 213 CFX_WideString& sError) { |
| 214 if (vp.IsGetting()) { | 214 if (vp.IsGetting()) { |
| 215 vp << JS_STR_PLATFORM; | 215 vp << JS_STR_PLATFORM; |
| 216 return TRUE; | 216 return TRUE; |
| 217 } | 217 } |
| 218 | 218 |
| 219 return FALSE; | 219 return FALSE; |
| 220 } | 220 } |
| 221 | 221 |
| 222 FX_BOOL app::language(IFXJS_Context* cc, | 222 FX_BOOL app::language(IJS_Context* cc, |
| 223 CJS_PropValue& vp, | 223 CJS_PropValue& vp, |
| 224 CFX_WideString& sError) { | 224 CFX_WideString& sError) { |
| 225 if (vp.IsGetting()) { | 225 if (vp.IsGetting()) { |
| 226 vp << JS_STR_LANGUANGE; | 226 vp << JS_STR_LANGUANGE; |
| 227 return TRUE; | 227 return TRUE; |
| 228 } | 228 } |
| 229 | 229 |
| 230 return FALSE; | 230 return FALSE; |
| 231 } | 231 } |
| 232 | 232 |
| 233 // creates a new fdf object that contains no data | 233 // creates a new fdf object that contains no data |
| 234 // comment: need reader support | 234 // comment: need reader support |
| 235 // note: | 235 // note: |
| 236 // CFDF_Document * CPDFDoc_Environment::NewFDF(); | 236 // CFDF_Document * CPDFDoc_Environment::NewFDF(); |
| 237 FX_BOOL app::newFDF(IFXJS_Context* cc, | 237 FX_BOOL app::newFDF(IJS_Context* cc, |
| 238 const CJS_Parameters& params, | 238 const CJS_Parameters& params, |
| 239 CJS_Value& vRet, | 239 CJS_Value& vRet, |
| 240 CFX_WideString& sError) { | 240 CFX_WideString& sError) { |
| 241 return TRUE; | 241 return TRUE; |
| 242 } | 242 } |
| 243 // opens a specified pdf document and returns its document object | 243 // opens a specified pdf document and returns its document object |
| 244 // comment:need reader support | 244 // comment:need reader support |
| 245 // note: as defined in js reference, the proto of this function's fourth | 245 // note: as defined in js reference, the proto of this function's fourth |
| 246 // parmeters, how old an fdf document while do not show it. | 246 // parmeters, how old an fdf document while do not show it. |
| 247 // CFDF_Document * CPDFDoc_Environment::OpenFDF(string strPath,bool bUserConv); | 247 // CFDF_Document * CPDFDoc_Environment::OpenFDF(string strPath,bool bUserConv); |
| 248 | 248 |
| 249 FX_BOOL app::openFDF(IFXJS_Context* cc, | 249 FX_BOOL app::openFDF(IJS_Context* cc, |
| 250 const CJS_Parameters& params, | 250 const CJS_Parameters& params, |
| 251 CJS_Value& vRet, | 251 CJS_Value& vRet, |
| 252 CFX_WideString& sError) { | 252 CFX_WideString& sError) { |
| 253 return TRUE; | 253 return TRUE; |
| 254 } | 254 } |
| 255 | 255 |
| 256 FX_BOOL app::alert(IFXJS_Context* cc, | 256 FX_BOOL app::alert(IJS_Context* cc, |
| 257 const CJS_Parameters& params, | 257 const CJS_Parameters& params, |
| 258 CJS_Value& vRet, | 258 CJS_Value& vRet, |
| 259 CFX_WideString& sError) { | 259 CFX_WideString& sError) { |
| 260 int iSize = params.size(); | 260 int iSize = params.size(); |
| 261 if (iSize < 1) | 261 if (iSize < 1) |
| 262 return FALSE; | 262 return FALSE; |
| 263 | 263 |
| 264 CFX_WideString swMsg = L""; | 264 CFX_WideString swMsg = L""; |
| 265 CFX_WideString swTitle = L""; | 265 CFX_WideString swTitle = L""; |
| 266 int iIcon = 0; | 266 int iIcon = 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 345 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 346 ASSERT(pRuntime != NULL); | 346 ASSERT(pRuntime != NULL); |
| 347 pRuntime->BeginBlock(); | 347 pRuntime->BeginBlock(); |
| 348 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, | 348 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, |
| 349 iIcon); | 349 iIcon); |
| 350 pRuntime->EndBlock(); | 350 pRuntime->EndBlock(); |
| 351 | 351 |
| 352 return TRUE; | 352 return TRUE; |
| 353 } | 353 } |
| 354 | 354 |
| 355 FX_BOOL app::beep(IFXJS_Context* cc, | 355 FX_BOOL app::beep(IJS_Context* cc, |
| 356 const CJS_Parameters& params, | 356 const CJS_Parameters& params, |
| 357 CJS_Value& vRet, | 357 CJS_Value& vRet, |
| 358 CFX_WideString& sError) { | 358 CFX_WideString& sError) { |
| 359 if (params.size() == 1) { | 359 if (params.size() == 1) { |
| 360 CJS_Context* pContext = (CJS_Context*)cc; | 360 CJS_Context* pContext = (CJS_Context*)cc; |
| 361 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 361 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 362 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 362 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
| 363 pEnv->JS_appBeep(params[0].ToInt()); | 363 pEnv->JS_appBeep(params[0].ToInt()); |
| 364 return TRUE; | 364 return TRUE; |
| 365 } | 365 } |
| 366 | 366 |
| 367 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 367 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
| 368 return FALSE; | 368 return FALSE; |
| 369 } | 369 } |
| 370 | 370 |
| 371 FX_BOOL app::findComponent(IFXJS_Context* cc, | 371 FX_BOOL app::findComponent(IJS_Context* cc, |
| 372 const CJS_Parameters& params, | 372 const CJS_Parameters& params, |
| 373 CJS_Value& vRet, | 373 CJS_Value& vRet, |
| 374 CFX_WideString& sError) { | 374 CFX_WideString& sError) { |
| 375 return TRUE; | 375 return TRUE; |
| 376 } | 376 } |
| 377 | 377 |
| 378 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, | 378 FX_BOOL app::popUpMenuEx(IJS_Context* cc, |
| 379 const CJS_Parameters& params, | 379 const CJS_Parameters& params, |
| 380 CJS_Value& vRet, | 380 CJS_Value& vRet, |
| 381 CFX_WideString& sError) { | 381 CFX_WideString& sError) { |
| 382 return FALSE; | 382 return FALSE; |
| 383 } | 383 } |
| 384 | 384 |
| 385 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 385 FX_BOOL app::fs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 386 return FALSE; | 386 return FALSE; |
| 387 } | 387 } |
| 388 | 388 |
| 389 FX_BOOL app::setInterval(IFXJS_Context* cc, | 389 FX_BOOL app::setInterval(IJS_Context* cc, |
| 390 const CJS_Parameters& params, | 390 const CJS_Parameters& params, |
| 391 CJS_Value& vRet, | 391 CJS_Value& vRet, |
| 392 CFX_WideString& sError) { | 392 CFX_WideString& sError) { |
| 393 CJS_Context* pContext = (CJS_Context*)cc; | 393 CJS_Context* pContext = (CJS_Context*)cc; |
| 394 if (params.size() > 2 || params.size() == 0) { | 394 if (params.size() > 2 || params.size() == 0) { |
| 395 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 395 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 396 return FALSE; | 396 return FALSE; |
| 397 } | 397 } |
| 398 | 398 |
| 399 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; | 399 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 415 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 415 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); |
| 416 CJS_TimerObj* pJS_TimerObj = | 416 CJS_TimerObj* pJS_TimerObj = |
| 417 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 417 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 418 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 418 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 419 pTimerObj->SetTimer(pTimer); | 419 pTimerObj->SetTimer(pTimer); |
| 420 | 420 |
| 421 vRet = pRetObj; | 421 vRet = pRetObj; |
| 422 return TRUE; | 422 return TRUE; |
| 423 } | 423 } |
| 424 | 424 |
| 425 FX_BOOL app::setTimeOut(IFXJS_Context* cc, | 425 FX_BOOL app::setTimeOut(IJS_Context* cc, |
| 426 const CJS_Parameters& params, | 426 const CJS_Parameters& params, |
| 427 CJS_Value& vRet, | 427 CJS_Value& vRet, |
| 428 CFX_WideString& sError) { | 428 CFX_WideString& sError) { |
| 429 if (params.size() > 2 || params.size() == 0) { | 429 if (params.size() > 2 || params.size() == 0) { |
| 430 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 430 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
| 431 return FALSE; | 431 return FALSE; |
| 432 } | 432 } |
| 433 | 433 |
| 434 CJS_Context* pContext = (CJS_Context*)cc; | 434 CJS_Context* pContext = (CJS_Context*)cc; |
| 435 ASSERT(pContext != NULL); | 435 ASSERT(pContext != NULL); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 456 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 456 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); |
| 457 CJS_TimerObj* pJS_TimerObj = | 457 CJS_TimerObj* pJS_TimerObj = |
| 458 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 458 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 459 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 459 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 460 pTimerObj->SetTimer(pTimer); | 460 pTimerObj->SetTimer(pTimer); |
| 461 | 461 |
| 462 vRet = pRetObj; | 462 vRet = pRetObj; |
| 463 return TRUE; | 463 return TRUE; |
| 464 } | 464 } |
| 465 | 465 |
| 466 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, | 466 FX_BOOL app::clearTimeOut(IJS_Context* cc, |
| 467 const CJS_Parameters& params, | 467 const CJS_Parameters& params, |
| 468 CJS_Value& vRet, | 468 CJS_Value& vRet, |
| 469 CFX_WideString& sError) { | 469 CFX_WideString& sError) { |
| 470 CJS_Context* pContext = (CJS_Context*)cc; | 470 CJS_Context* pContext = (CJS_Context*)cc; |
| 471 if (params.size() != 1) { | 471 if (params.size() != 1) { |
| 472 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 472 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 473 return FALSE; | 473 return FALSE; |
| 474 } | 474 } |
| 475 | 475 |
| 476 if (params[0].GetType() == CJS_Value::VT_fxobject) { | 476 if (params[0].GetType() == CJS_Value::VT_fxobject) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 492 pTimerObj->SetTimer(NULL); | 492 pTimerObj->SetTimer(NULL); |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 | 498 |
| 499 return TRUE; | 499 return TRUE; |
| 500 } | 500 } |
| 501 | 501 |
| 502 FX_BOOL app::clearInterval(IFXJS_Context* cc, | 502 FX_BOOL app::clearInterval(IJS_Context* cc, |
| 503 const CJS_Parameters& params, | 503 const CJS_Parameters& params, |
| 504 CJS_Value& vRet, | 504 CJS_Value& vRet, |
| 505 CFX_WideString& sError) { | 505 CFX_WideString& sError) { |
| 506 CJS_Context* pContext = (CJS_Context*)cc; | 506 CJS_Context* pContext = (CJS_Context*)cc; |
| 507 if (params.size() != 1) { | 507 if (params.size() != 1) { |
| 508 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 508 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 509 return FALSE; | 509 return FALSE; |
| 510 } | 510 } |
| 511 | 511 |
| 512 if (params[0].GetType() == CJS_Value::VT_fxobject) { | 512 if (params[0].GetType() == CJS_Value::VT_fxobject) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 528 pTimerObj->SetTimer(NULL); | 528 pTimerObj->SetTimer(NULL); |
| 529 } | 529 } |
| 530 } | 530 } |
| 531 } | 531 } |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 | 534 |
| 535 return TRUE; | 535 return TRUE; |
| 536 } | 536 } |
| 537 | 537 |
| 538 FX_BOOL app::execMenuItem(IFXJS_Context* cc, | 538 FX_BOOL app::execMenuItem(IJS_Context* cc, |
| 539 const CJS_Parameters& params, | 539 const CJS_Parameters& params, |
| 540 CJS_Value& vRet, | 540 CJS_Value& vRet, |
| 541 CFX_WideString& sError) { | 541 CFX_WideString& sError) { |
| 542 return FALSE; | 542 return FALSE; |
| 543 } | 543 } |
| 544 | 544 |
| 545 void app::TimerProc(CJS_Timer* pTimer) { | 545 void app::TimerProc(CJS_Timer* pTimer) { |
| 546 ASSERT(pTimer != NULL); | 546 ASSERT(pTimer != NULL); |
| 547 | 547 |
| 548 CJS_Runtime* pRuntime = pTimer->GetRuntime(); | 548 CJS_Runtime* pRuntime = pTimer->GetRuntime(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 559 pTimer->KillJSTimer(); | 559 pTimer->KillJSTimer(); |
| 560 } | 560 } |
| 561 break; | 561 break; |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { | 565 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { |
| 566 ASSERT(pRuntime != NULL); | 566 ASSERT(pRuntime != NULL); |
| 567 | 567 |
| 568 if (!pRuntime->IsBlocking()) { | 568 if (!pRuntime->IsBlocking()) { |
| 569 IFXJS_Context* pContext = pRuntime->NewContext(); | 569 IJS_Context* pContext = pRuntime->NewContext(); |
| 570 ASSERT(pContext != NULL); | 570 ASSERT(pContext != NULL); |
| 571 pContext->OnExternal_Exec(); | 571 pContext->OnExternal_Exec(); |
| 572 CFX_WideString wtInfo; | 572 CFX_WideString wtInfo; |
| 573 pContext->RunScript(wsScript, wtInfo); | 573 pContext->RunScript(wsScript, wtInfo); |
| 574 pRuntime->ReleaseContext(pContext); | 574 pRuntime->ReleaseContext(pContext); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 FX_BOOL app::goBack(IFXJS_Context* cc, | 578 FX_BOOL app::goBack(IJS_Context* cc, |
| 579 const CJS_Parameters& params, | 579 const CJS_Parameters& params, |
| 580 CJS_Value& vRet, | 580 CJS_Value& vRet, |
| 581 CFX_WideString& sError) { | 581 CFX_WideString& sError) { |
| 582 // Not supported. | 582 // Not supported. |
| 583 return TRUE; | 583 return TRUE; |
| 584 } | 584 } |
| 585 | 585 |
| 586 FX_BOOL app::goForward(IFXJS_Context* cc, | 586 FX_BOOL app::goForward(IJS_Context* cc, |
| 587 const CJS_Parameters& params, | 587 const CJS_Parameters& params, |
| 588 CJS_Value& vRet, | 588 CJS_Value& vRet, |
| 589 CFX_WideString& sError) { | 589 CFX_WideString& sError) { |
| 590 // Not supported. | 590 // Not supported. |
| 591 return TRUE; | 591 return TRUE; |
| 592 } | 592 } |
| 593 | 593 |
| 594 FX_BOOL app::mailMsg(IFXJS_Context* cc, | 594 FX_BOOL app::mailMsg(IJS_Context* cc, |
| 595 const CJS_Parameters& params, | 595 const CJS_Parameters& params, |
| 596 CJS_Value& vRet, | 596 CJS_Value& vRet, |
| 597 CFX_WideString& sError) { | 597 CFX_WideString& sError) { |
| 598 CJS_Context* pContext = (CJS_Context*)cc; | 598 CJS_Context* pContext = (CJS_Context*)cc; |
| 599 v8::Isolate* isolate = GetIsolate(cc); | 599 v8::Isolate* isolate = GetIsolate(cc); |
| 600 | 600 |
| 601 FX_BOOL bUI = TRUE; | 601 FX_BOOL bUI = TRUE; |
| 602 CFX_WideString cTo = L""; | 602 CFX_WideString cTo = L""; |
| 603 CFX_WideString cCc = L""; | 603 CFX_WideString cCc = L""; |
| 604 CFX_WideString cBcc = L""; | 604 CFX_WideString cBcc = L""; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 ASSERT(pApp != NULL); | 653 ASSERT(pApp != NULL); |
| 654 | 654 |
| 655 pRuntime->BeginBlock(); | 655 pRuntime->BeginBlock(); |
| 656 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), | 656 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), |
| 657 cBcc.c_str(), cMsg.c_str()); | 657 cBcc.c_str(), cMsg.c_str()); |
| 658 pRuntime->EndBlock(); | 658 pRuntime->EndBlock(); |
| 659 | 659 |
| 660 return FALSE; | 660 return FALSE; |
| 661 } | 661 } |
| 662 | 662 |
| 663 FX_BOOL app::launchURL(IFXJS_Context* cc, | 663 FX_BOOL app::launchURL(IJS_Context* cc, |
| 664 const CJS_Parameters& params, | 664 const CJS_Parameters& params, |
| 665 CJS_Value& vRet, | 665 CJS_Value& vRet, |
| 666 CFX_WideString& sError) { | 666 CFX_WideString& sError) { |
| 667 // Unsafe, not supported. | 667 // Unsafe, not supported. |
| 668 return TRUE; | 668 return TRUE; |
| 669 } | 669 } |
| 670 | 670 |
| 671 FX_BOOL app::runtimeHighlight(IFXJS_Context* cc, | 671 FX_BOOL app::runtimeHighlight(IJS_Context* cc, |
| 672 CJS_PropValue& vp, | 672 CJS_PropValue& vp, |
| 673 CFX_WideString& sError) { | 673 CFX_WideString& sError) { |
| 674 if (vp.IsSetting()) { | 674 if (vp.IsSetting()) { |
| 675 vp >> m_bRuntimeHighLight; | 675 vp >> m_bRuntimeHighLight; |
| 676 } else { | 676 } else { |
| 677 vp << m_bRuntimeHighLight; | 677 vp << m_bRuntimeHighLight; |
| 678 } | 678 } |
| 679 | 679 |
| 680 return TRUE; | 680 return TRUE; |
| 681 } | 681 } |
| 682 | 682 |
| 683 FX_BOOL app::fullscreen(IFXJS_Context* cc, | 683 FX_BOOL app::fullscreen(IJS_Context* cc, |
| 684 CJS_PropValue& vp, | 684 CJS_PropValue& vp, |
| 685 CFX_WideString& sError) { | 685 CFX_WideString& sError) { |
| 686 return FALSE; | 686 return FALSE; |
| 687 } | 687 } |
| 688 | 688 |
| 689 FX_BOOL app::popUpMenu(IFXJS_Context* cc, | 689 FX_BOOL app::popUpMenu(IJS_Context* cc, |
| 690 const CJS_Parameters& params, | 690 const CJS_Parameters& params, |
| 691 CJS_Value& vRet, | 691 CJS_Value& vRet, |
| 692 CFX_WideString& sError) { | 692 CFX_WideString& sError) { |
| 693 return FALSE; | 693 return FALSE; |
| 694 } | 694 } |
| 695 | 695 |
| 696 FX_BOOL app::browseForDoc(IFXJS_Context* cc, | 696 FX_BOOL app::browseForDoc(IJS_Context* cc, |
| 697 const CJS_Parameters& params, | 697 const CJS_Parameters& params, |
| 698 CJS_Value& vRet, | 698 CJS_Value& vRet, |
| 699 CFX_WideString& sError) { | 699 CFX_WideString& sError) { |
| 700 // Unsafe, not supported. | 700 // Unsafe, not supported. |
| 701 return TRUE; | 701 return TRUE; |
| 702 } | 702 } |
| 703 | 703 |
| 704 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) { | 704 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) { |
| 705 CFX_WideString sRet = L"/"; | 705 CFX_WideString sRet = L"/"; |
| 706 | 706 |
| 707 for (int i = 0, sz = sOldPath.GetLength(); i < sz; i++) { | 707 for (int i = 0, sz = sOldPath.GetLength(); i < sz; i++) { |
| 708 wchar_t c = sOldPath.GetAt(i); | 708 wchar_t c = sOldPath.GetAt(i); |
| 709 if (c == L':') { | 709 if (c == L':') { |
| 710 } else { | 710 } else { |
| 711 if (c == L'\\') { | 711 if (c == L'\\') { |
| 712 sRet += L"/"; | 712 sRet += L"/"; |
| 713 } else { | 713 } else { |
| 714 sRet += c; | 714 sRet += c; |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 return sRet; | 719 return sRet; |
| 720 } | 720 } |
| 721 | 721 |
| 722 FX_BOOL app::newDoc(IFXJS_Context* cc, | 722 FX_BOOL app::newDoc(IJS_Context* cc, |
| 723 const CJS_Parameters& params, | 723 const CJS_Parameters& params, |
| 724 CJS_Value& vRet, | 724 CJS_Value& vRet, |
| 725 CFX_WideString& sError) { | 725 CFX_WideString& sError) { |
| 726 return FALSE; | 726 return FALSE; |
| 727 } | 727 } |
| 728 | 728 |
| 729 FX_BOOL app::openDoc(IFXJS_Context* cc, | 729 FX_BOOL app::openDoc(IJS_Context* cc, |
| 730 const CJS_Parameters& params, | 730 const CJS_Parameters& params, |
| 731 CJS_Value& vRet, | 731 CJS_Value& vRet, |
| 732 CFX_WideString& sError) { | 732 CFX_WideString& sError) { |
| 733 return FALSE; | 733 return FALSE; |
| 734 } | 734 } |
| 735 | 735 |
| 736 FX_BOOL app::response(IFXJS_Context* cc, | 736 FX_BOOL app::response(IJS_Context* cc, |
| 737 const CJS_Parameters& params, | 737 const CJS_Parameters& params, |
| 738 CJS_Value& vRet, | 738 CJS_Value& vRet, |
| 739 CFX_WideString& sError) { | 739 CFX_WideString& sError) { |
| 740 CFX_WideString swQuestion = L""; | 740 CFX_WideString swQuestion = L""; |
| 741 CFX_WideString swLabel = L""; | 741 CFX_WideString swLabel = L""; |
| 742 CFX_WideString swTitle = L"PDF"; | 742 CFX_WideString swTitle = L"PDF"; |
| 743 CFX_WideString swDefault = L""; | 743 CFX_WideString swDefault = L""; |
| 744 bool bPassWord = false; | 744 bool bPassWord = false; |
| 745 | 745 |
| 746 v8::Isolate* isolate = GetIsolate(cc); | 746 v8::Isolate* isolate = GetIsolate(cc); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 return FALSE; | 806 return FALSE; |
| 807 } | 807 } |
| 808 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); | 808 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); |
| 809 | 809 |
| 810 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( | 810 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( |
| 811 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); | 811 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); |
| 812 vRet = ret_string.c_str(); | 812 vRet = ret_string.c_str(); |
| 813 return TRUE; | 813 return TRUE; |
| 814 } | 814 } |
| 815 | 815 |
| 816 FX_BOOL app::media(IFXJS_Context* cc, | 816 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 817 CJS_PropValue& vp, | |
| 818 CFX_WideString& sError) { | |
| 819 return FALSE; | 817 return FALSE; |
| 820 } | 818 } |
| 821 | 819 |
| 822 FX_BOOL app::execDialog(IFXJS_Context* cc, | 820 FX_BOOL app::execDialog(IJS_Context* cc, |
| 823 const CJS_Parameters& params, | 821 const CJS_Parameters& params, |
| 824 CJS_Value& vRet, | 822 CJS_Value& vRet, |
| 825 CFX_WideString& sError) { | 823 CFX_WideString& sError) { |
| 826 return TRUE; | 824 return TRUE; |
| 827 } | 825 } |
| OLD | NEW |