| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| 11 #include "../../include/javascript/JS_Value.h" | 11 #include "../../include/javascript/JS_Value.h" |
| 12 #include "../../include/javascript/app.h" | 12 #include "../../include/javascript/app.h" |
| 13 #include "../../include/javascript/JS_EventHandler.h" | 13 #include "../../include/javascript/JS_EventHandler.h" |
| 14 #include "../../include/javascript/resource.h" | 14 #include "../../include/javascript/resource.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) | 39 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) |
| 40 END_JS_STATIC_METHOD() | 40 END_JS_STATIC_METHOD() |
| 41 | 41 |
| 42 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) | 42 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) |
| 43 | 43 |
| 44 TimerObj::TimerObj(CJS_Object* pJSObject) | 44 TimerObj::TimerObj(CJS_Object* pJSObject) |
| 45 : CJS_EmbedObj(pJSObject), | 45 : CJS_EmbedObj(pJSObject), |
| 46 m_pTimer(NULL) | 46 m_pTimer(NULL) |
| 47 { | 47 { |
| 48 » | 48 |
| 49 } | 49 } |
| 50 | 50 |
| 51 TimerObj::~TimerObj() | 51 TimerObj::~TimerObj() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 void TimerObj::SetTimer(CJS_Timer* pTimer) | 55 void TimerObj::SetTimer(CJS_Timer* pTimer) |
| 56 { | 56 { |
| 57 m_pTimer = pTimer; | 57 m_pTimer = pTimer; |
| 58 } | 58 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 83 JS_STATIC_PROP_ENTRY(calculate) | 83 JS_STATIC_PROP_ENTRY(calculate) |
| 84 JS_STATIC_PROP_ENTRY(formsVersion) | 84 JS_STATIC_PROP_ENTRY(formsVersion) |
| 85 JS_STATIC_PROP_ENTRY(fs) | 85 JS_STATIC_PROP_ENTRY(fs) |
| 86 JS_STATIC_PROP_ENTRY(fullscreen) | 86 JS_STATIC_PROP_ENTRY(fullscreen) |
| 87 JS_STATIC_PROP_ENTRY(language) | 87 JS_STATIC_PROP_ENTRY(language) |
| 88 JS_STATIC_PROP_ENTRY(media) | 88 JS_STATIC_PROP_ENTRY(media) |
| 89 JS_STATIC_PROP_ENTRY(platform) | 89 JS_STATIC_PROP_ENTRY(platform) |
| 90 JS_STATIC_PROP_ENTRY(runtimeHighlight) | 90 JS_STATIC_PROP_ENTRY(runtimeHighlight) |
| 91 JS_STATIC_PROP_ENTRY(viewerType) | 91 JS_STATIC_PROP_ENTRY(viewerType) |
| 92 JS_STATIC_PROP_ENTRY(viewerVariation) | 92 JS_STATIC_PROP_ENTRY(viewerVariation) |
| 93 » JS_STATIC_PROP_ENTRY(viewerVersion)» | 93 » JS_STATIC_PROP_ENTRY(viewerVersion) |
| 94 END_JS_STATIC_PROP() | 94 END_JS_STATIC_PROP() |
| 95 | 95 |
| 96 BEGIN_JS_STATIC_METHOD(CJS_App) | 96 BEGIN_JS_STATIC_METHOD(CJS_App) |
| 97 JS_STATIC_METHOD_ENTRY(alert, 6) | 97 JS_STATIC_METHOD_ENTRY(alert, 6) |
| 98 JS_STATIC_METHOD_ENTRY(beep, 1) | 98 JS_STATIC_METHOD_ENTRY(beep, 1) |
| 99 JS_STATIC_METHOD_ENTRY(browseForDoc, 0) | 99 JS_STATIC_METHOD_ENTRY(browseForDoc, 0) |
| 100 JS_STATIC_METHOD_ENTRY(clearInterval, 1) | 100 JS_STATIC_METHOD_ENTRY(clearInterval, 1) |
| 101 JS_STATIC_METHOD_ENTRY(clearTimeOut, 1) | 101 JS_STATIC_METHOD_ENTRY(clearTimeOut, 1) |
| 102 JS_STATIC_METHOD_ENTRY(execDialog, 3) | 102 JS_STATIC_METHOD_ENTRY(execDialog, 3) |
| 103 JS_STATIC_METHOD_ENTRY(execMenuItem, 1) | 103 JS_STATIC_METHOD_ENTRY(execMenuItem, 1) |
| 104 JS_STATIC_METHOD_ENTRY(findComponent, 1) | 104 JS_STATIC_METHOD_ENTRY(findComponent, 1) |
| 105 JS_STATIC_METHOD_ENTRY(goBack, 0) | 105 JS_STATIC_METHOD_ENTRY(goBack, 0) |
| 106 JS_STATIC_METHOD_ENTRY(goForward, 0) | 106 JS_STATIC_METHOD_ENTRY(goForward, 0) |
| 107 JS_STATIC_METHOD_ENTRY(launchURL, 0) | 107 JS_STATIC_METHOD_ENTRY(launchURL, 0) |
| 108 » JS_STATIC_METHOD_ENTRY(mailMsg, 0)» | 108 » JS_STATIC_METHOD_ENTRY(mailMsg, 0) |
| 109 JS_STATIC_METHOD_ENTRY(newFDF, 0) | 109 JS_STATIC_METHOD_ENTRY(newFDF, 0) |
| 110 JS_STATIC_METHOD_ENTRY(newDoc, 0) | 110 JS_STATIC_METHOD_ENTRY(newDoc, 0) |
| 111 JS_STATIC_METHOD_ENTRY(openDoc, 0) | 111 JS_STATIC_METHOD_ENTRY(openDoc, 0) |
| 112 JS_STATIC_METHOD_ENTRY(openFDF, 5) | 112 JS_STATIC_METHOD_ENTRY(openFDF, 5) |
| 113 JS_STATIC_METHOD_ENTRY(popUpMenuEx, 0) | 113 JS_STATIC_METHOD_ENTRY(popUpMenuEx, 0) |
| 114 JS_STATIC_METHOD_ENTRY(popUpMenu, 0) | 114 JS_STATIC_METHOD_ENTRY(popUpMenu, 0) |
| 115 JS_STATIC_METHOD_ENTRY(response, 0) | 115 JS_STATIC_METHOD_ENTRY(response, 0) |
| 116 JS_STATIC_METHOD_ENTRY(setInterval, 2) | 116 JS_STATIC_METHOD_ENTRY(setInterval, 2) |
| 117 JS_STATIC_METHOD_ENTRY(setTimeOut, 2) | 117 JS_STATIC_METHOD_ENTRY(setTimeOut, 2) |
| 118 END_JS_STATIC_METHOD() | 118 END_JS_STATIC_METHOD() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 134 m_aTimer.RemoveAll(); | 134 m_aTimer.RemoveAll(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 FX_BOOL app::activeDocs(OBJ_PROP_PARAMS) | 137 FX_BOOL app::activeDocs(OBJ_PROP_PARAMS) |
| 138 { | 138 { |
| 139 if (vp.IsGetting()) | 139 if (vp.IsGetting()) |
| 140 { | 140 { |
| 141 | 141 |
| 142 CJS_Context* pContext = (CJS_Context *)cc; | 142 CJS_Context* pContext = (CJS_Context *)cc; |
| 143 ASSERT(pContext != NULL); | 143 ASSERT(pContext != NULL); |
| 144 » » | 144 |
| 145 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 145 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 146 ASSERT(pApp != NULL); | 146 ASSERT(pApp != NULL); |
| 147 | 147 |
| 148 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 148 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 149 ASSERT(pRuntime != NULL); | 149 ASSERT(pRuntime != NULL); |
| 150 » » | 150 |
| 151 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 151 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 152 » » | 152 |
| 153 CJS_Array aDocs(pRuntime->GetIsolate()); | 153 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 154 // int iNumDocs = pApp->CountDocuments(); | 154 // int iNumDocs = pApp->CountDocuments(); |
| 155 » » | 155 |
| 156 // for(int iIndex = 0; iIndex<iNumDocs; iIndex++) | 156 // for(int iIndex = 0; iIndex<iNumDocs; iIndex++) |
| 157 // { | 157 // { |
| 158 CPDFSDK_Document* pDoc = pApp->GetCurrentDoc(); | 158 CPDFSDK_Document* pDoc = pApp->GetCurrentDoc(); |
| 159 if (pDoc) | 159 if (pDoc) |
| 160 { | 160 { |
| 161 CJS_Document * pJSDocument = NULL; | 161 CJS_Document * pJSDocument = NULL; |
| 162 » » » » | 162 |
| 163 if (pDoc == pCurDoc) | 163 if (pDoc == pCurDoc) |
| 164 { | 164 { |
| 165 JSFXObject pObj = JS_GetThisObj(*pRuntim
e); | 165 JSFXObject pObj = JS_GetThisObj(*pRuntim
e); |
| 166 » » » » » | 166 |
| 167 if (JS_GetObjDefnID(pObj) == JS_GetObjDe
fnID(*pRuntime, L"Document")) | 167 if (JS_GetObjDefnID(pObj) == JS_GetObjDe
fnID(*pRuntime, L"Document")) |
| 168 { | 168 { |
| 169 pJSDocument = (CJS_Document*)JS_
GetPrivate(pRuntime->GetIsolate(),pObj); | 169 pJSDocument = (CJS_Document*)JS_
GetPrivate(pRuntime->GetIsolate(),pObj); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 else | 172 else |
| 173 { | 173 { |
| 174 JSFXObject pObj = JS_NewFxDynamicObj(*pR
untime, pContext, JS_GetObjDefnID(*pRuntime,L"Document")); | 174 JSFXObject pObj = JS_NewFxDynamicObj(*pR
untime, pContext, JS_GetObjDefnID(*pRuntime,L"Document")); |
| 175 pJSDocument = (CJS_Document*)JS_GetPriva
te(pRuntime->GetIsolate(),pObj); | 175 pJSDocument = (CJS_Document*)JS_GetPriva
te(pRuntime->GetIsolate(),pObj); |
| 176 ASSERT(pJSDocument != NULL); | 176 ASSERT(pJSDocument != NULL); |
| 177 » » » » » | 177 |
| 178 » » » » » | 178 |
| 179 // pDocument->Attac
hDoc(pDoc); | 179 // pDocument->Attac
hDoc(pDoc); |
| 180 } | 180 } |
| 181 » » » » | 181 |
| 182 aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolat
e(),pJSDocument)); | 182 aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolat
e(),pJSDocument)); |
| 183 } | 183 } |
| 184 // } | 184 // } |
| 185 » » | 185 |
| 186 if (aDocs.GetLength() > 0) | 186 if (aDocs.GetLength() > 0) |
| 187 vp << aDocs; | 187 vp << aDocs; |
| 188 else | 188 else |
| 189 vp.SetNull(); | 189 vp.SetNull(); |
| 190 return TRUE; | 190 return TRUE; |
| 191 } | 191 } |
| 192 return FALSE; | 192 return FALSE; |
| 193 } | 193 } |
| 194 | 194 |
| 195 FX_BOOL app::calculate(OBJ_PROP_PARAMS) | 195 FX_BOOL app::calculate(OBJ_PROP_PARAMS) |
| 196 { | 196 { |
| 197 if (vp.IsSetting()) | 197 if (vp.IsSetting()) |
| 198 { | 198 { |
| 199 bool bVP; | 199 bool bVP; |
| 200 vp >> bVP; | 200 vp >> bVP; |
| 201 m_bCalculate = (FX_BOOL)bVP; | 201 m_bCalculate = (FX_BOOL)bVP; |
| 202 | 202 |
| 203 CJS_Context* pContext = (CJS_Context*)cc; | 203 CJS_Context* pContext = (CJS_Context*)cc; |
| 204 ASSERT(pContext != NULL); | 204 ASSERT(pContext != NULL); |
| 205 » » | 205 |
| 206 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 206 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 207 ASSERT(pApp != NULL); | 207 ASSERT(pApp != NULL); |
| 208 » » | 208 |
| 209 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 209 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 210 ASSERT(pRuntime != NULL); | 210 ASSERT(pRuntime != NULL); |
| 211 | 211 |
| 212 CJS_Array aDocs(pRuntime->GetIsolate()); | 212 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 213 // int iNumDocs = pApp->CountDocuments(); | 213 // int iNumDocs = pApp->CountDocuments(); |
| 214 //» » | 214 // |
| 215 // for (int iIndex = 0;iIndex < iNumDocs; iIndex++) | 215 // for (int iIndex = 0;iIndex < iNumDocs; iIndex++) |
| 216 // { | 216 // { |
| 217 if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc()) | 217 if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc()) |
| 218 { | 218 { |
| 219 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterFo
rm*)pDoc->GetInterForm(); | 219 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterFo
rm*)pDoc->GetInterForm(); |
| 220 ASSERT(pInterForm != NULL); | 220 ASSERT(pInterForm != NULL); |
| 221 pInterForm->EnableCalculate((FX_BOOL)m_bCalculat
e); | 221 pInterForm->EnableCalculate((FX_BOOL)m_bCalculat
e); |
| 222 » » » }» » » | 222 » » » } |
| 223 // } | 223 // } |
| 224 } | 224 } |
| 225 else | 225 else |
| 226 { | 226 { |
| 227 vp << (bool)m_bCalculate; | 227 vp << (bool)m_bCalculate; |
| 228 } | 228 } |
| 229 » | 229 |
| 230 return TRUE; | 230 return TRUE; |
| 231 } | 231 } |
| 232 | 232 |
| 233 FX_BOOL app::formsVersion(OBJ_PROP_PARAMS) | 233 FX_BOOL app::formsVersion(OBJ_PROP_PARAMS) |
| 234 { | 234 { |
| 235 if (vp.IsGetting()) | 235 if (vp.IsGetting()) |
| 236 { | 236 { |
| 237 vp << JS_NUM_FORMSVERSION; | 237 vp << JS_NUM_FORMSVERSION; |
| 238 return TRUE; | 238 return TRUE; |
| 239 } | 239 } |
| 240 » | 240 |
| 241 return FALSE; | 241 return FALSE; |
| 242 } | 242 } |
| 243 | 243 |
| 244 FX_BOOL app::viewerType(OBJ_PROP_PARAMS) | 244 FX_BOOL app::viewerType(OBJ_PROP_PARAMS) |
| 245 { | 245 { |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 if (vp.IsGetting()) | 246 if (vp.IsGetting()) |
| 253 { | 247 { |
| 254 // if (pApp->GetAppName() == PHANTOM) | |
| 255 // vp << JS_STR_VIEWERTYPE_STANDARD; | |
| 256 // else | |
| 257 // vp << JS_STR_VIEWERTYPE_READER; | |
| 258 vp << L"unknown"; | 248 vp << L"unknown"; |
| 259 | |
| 260 //vp << pApp->GetAppTitle(); | |
| 261 return TRUE; | 249 return TRUE; |
| 262 } | 250 } |
| 263 » | 251 |
| 264 return FALSE; | 252 return FALSE; |
| 265 } | 253 } |
| 266 | 254 |
| 267 FX_BOOL app::viewerVariation(OBJ_PROP_PARAMS) | 255 FX_BOOL app::viewerVariation(OBJ_PROP_PARAMS) |
| 268 { | 256 { |
| 269 if (vp.IsGetting()) | 257 if (vp.IsGetting()) |
| 270 { | 258 { |
| 271 vp << JS_STR_VIEWERVARIATION; | 259 vp << JS_STR_VIEWERVARIATION; |
| 272 return TRUE; | 260 return TRUE; |
| 273 } | 261 } |
| 274 » | 262 |
| 275 return FALSE; | 263 return FALSE; |
| 276 } | 264 } |
| 277 | 265 |
| 278 FX_BOOL app::viewerVersion(OBJ_PROP_PARAMS) | 266 FX_BOOL app::viewerVersion(OBJ_PROP_PARAMS) |
| 279 { | 267 { |
| 280 if (vp.IsGetting()) | 268 if (vp.IsGetting()) |
| 281 { | 269 { |
| 282 CJS_Context* pContext = (CJS_Context *)cc; | 270 CJS_Context* pContext = (CJS_Context *)cc; |
| 283 ASSERT(pContext != NULL); | 271 ASSERT(pContext != NULL); |
| 284 » » | 272 |
| 285 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 273 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 286 ASSERT(pApp != NULL); | 274 ASSERT(pApp != NULL); |
| 287 » » | 275 |
| 288 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 276 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 289 | 277 |
| 290 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); | 278 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); |
| 291 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) | 279 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) |
| 292 vp << JS_STR_VIEWERVERSION_XFA; | 280 vp << JS_STR_VIEWERVERSION_XFA; |
| 293 else | 281 else |
| 294 vp << JS_STR_VIEWERVERSION; | 282 vp << JS_STR_VIEWERVERSION; |
| 295 return TRUE; | 283 return TRUE; |
| 296 } | 284 } |
| 297 » | 285 |
| 298 return FALSE; | 286 return FALSE; |
| 299 } | 287 } |
| 300 | 288 |
| 301 FX_BOOL app::platform(OBJ_PROP_PARAMS) | 289 FX_BOOL app::platform(OBJ_PROP_PARAMS) |
| 302 { | 290 { |
| 303 if (vp.IsGetting()) | 291 if (vp.IsGetting()) |
| 304 { | 292 { |
| 305 vp << JS_STR_PLATFORM; | 293 vp << JS_STR_PLATFORM; |
| 306 return TRUE; | 294 return TRUE; |
| 307 } | 295 } |
| 308 » | 296 |
| 309 return FALSE; | 297 return FALSE; |
| 310 } | 298 } |
| 311 | 299 |
| 312 FX_BOOL app::language(OBJ_PROP_PARAMS) | 300 FX_BOOL app::language(OBJ_PROP_PARAMS) |
| 313 { | 301 { |
| 314 if (vp.IsGetting()) | 302 if (vp.IsGetting()) |
| 315 { | 303 { |
| 316 vp << JS_STR_LANGUANGE; | 304 vp << JS_STR_LANGUANGE; |
| 317 return TRUE; | 305 return TRUE; |
| 318 } | 306 } |
| 319 » | 307 |
| 320 return FALSE; | 308 return FALSE; |
| 321 } | 309 } |
| 322 | 310 |
| 323 //creates a new fdf object that contains no data | 311 //creates a new fdf object that contains no data |
| 324 //comment: need reader support | 312 //comment: need reader support |
| 325 //note: | 313 //note: |
| 326 //CFDF_Document * CPDFDoc_Environment::NewFDF(); | 314 //CFDF_Document * CPDFDoc_Environment::NewFDF(); |
| 327 FX_BOOL app::newFDF(OBJ_METHOD_PARAMS) | 315 FX_BOOL app::newFDF(OBJ_METHOD_PARAMS) |
| 328 { | 316 { |
| 329 return TRUE; | 317 return TRUE; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 if (bGet) | 419 if (bGet) |
| 432 swMsg = L"true"; | 420 swMsg = L"true"; |
| 433 else | 421 else |
| 434 swMsg = L"false"; | 422 swMsg = L"false"; |
| 435 } | 423 } |
| 436 else | 424 else |
| 437 { | 425 { |
| 438 swMsg = params[0]; | 426 swMsg = params[0]; |
| 439 } | 427 } |
| 440 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT
); | 428 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT
); |
| 441 » » | 429 |
| 442 for(int i = 1;i<iSize;i++) | 430 for(int i = 1;i<iSize;i++) |
| 443 { | 431 { |
| 444 if (i == 1) | 432 if (i == 1) |
| 445 iIcon = int(params[i]); | 433 iIcon = int(params[i]); |
| 446 if (i == 2) | 434 if (i == 2) |
| 447 iType = int(params[i]); | 435 iType = int(params[i]); |
| 448 if (i == 3) | 436 if (i == 3) |
| 449 » » » » swTitle = params[i];» » » | 437 » » » » swTitle = params[i]; |
| 450 } | 438 } |
| 451 } | 439 } |
| 452 | 440 |
| 453 | 441 |
| 454 CJS_Context* pContext = (CJS_Context*)cc; | 442 CJS_Context* pContext = (CJS_Context*)cc; |
| 455 ASSERT(pContext != NULL); | 443 ASSERT(pContext != NULL); |
| 456 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 444 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 457 ASSERT(pRuntime != NULL); | 445 ASSERT(pRuntime != NULL); |
| 458 pRuntime->BeginBlock(); | 446 pRuntime->BeginBlock(); |
| 459 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); | 447 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); |
| 460 pRuntime->EndBlock(); | 448 pRuntime->EndBlock(); |
| 461 » | 449 |
| 462 return TRUE; | 450 return TRUE; |
| 463 } | 451 } |
| 464 | 452 |
| 465 | 453 |
| 466 FX_BOOL app::beep(OBJ_METHOD_PARAMS) | 454 FX_BOOL app::beep(OBJ_METHOD_PARAMS) |
| 467 { | 455 { |
| 468 if (params.size() == 1) | 456 if (params.size() == 1) |
| 469 { | 457 { |
| 470 CJS_Context* pContext = (CJS_Context*)cc; | 458 CJS_Context* pContext = (CJS_Context*)cc; |
| 471 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 459 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 472 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp(); | 460 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp(); |
| 473 pEnv->JS_appBeep((int)params[0]); | 461 pEnv->JS_appBeep((int)params[0]); |
| 474 | 462 |
| 475 return TRUE; | 463 return TRUE; |
| 476 } | 464 } |
| 477 else | 465 else |
| 478 { | 466 { |
| 479 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 467 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 480 return FALSE; | 468 return FALSE; |
| 481 } | 469 } |
| 482 } | 470 } |
| 483 | 471 |
| 484 FX_BOOL app::findComponent(OBJ_METHOD_PARAMS) | 472 FX_BOOL app::findComponent(OBJ_METHOD_PARAMS) |
| 485 { | 473 { |
| 486 return TRUE; | 474 return TRUE; |
| 487 } | 475 } |
| 488 | 476 |
| 489 FX_BOOL app::popUpMenuEx(OBJ_METHOD_PARAMS) | 477 FX_BOOL app::popUpMenuEx(OBJ_METHOD_PARAMS) |
| 490 {» | 478 { |
| 491 return FALSE; | 479 return FALSE; |
| 492 } | 480 } |
| 493 | 481 |
| 494 FX_BOOL app::fs(OBJ_PROP_PARAMS) | 482 FX_BOOL app::fs(OBJ_PROP_PARAMS) |
| 495 { | 483 { |
| 496 return FALSE; | 484 return FALSE; |
| 497 } | 485 } |
| 498 | 486 |
| 499 FX_BOOL app::setInterval(OBJ_METHOD_PARAMS) | 487 FX_BOOL app::setInterval(OBJ_METHOD_PARAMS) |
| 500 { | 488 { |
| 501 » if (params.size() > 2 || params.size() == 0) | 489 » if (params.size() > 2 || params.size() == 0) |
| 502 { | 490 { |
| 503 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR);» | 491 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 504 return FALSE; | 492 return FALSE; |
| 505 } | 493 } |
| 506 » | 494 |
| 507 CJS_Context* pContext = (CJS_Context*)cc; | 495 CJS_Context* pContext = (CJS_Context*)cc; |
| 508 ASSERT(pContext != NULL); | 496 ASSERT(pContext != NULL); |
| 509 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 497 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 510 ASSERT(pRuntime != NULL); | 498 ASSERT(pRuntime != NULL); |
| 511 | 499 |
| 512 CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; | 500 CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; |
| 513 » if (script.IsEmpty()) | 501 » if (script.IsEmpty()) |
| 514 { | 502 { |
| 515 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 503 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
| 516 return TRUE; | 504 return TRUE; |
| 517 } | 505 } |
| 518 | 506 |
| 519 FX_DWORD dwInterval = params.size() > 1 ? (int)params[1] : 1000; | 507 FX_DWORD dwInterval = params.size() > 1 ? (int)params[1] : 1000; |
| 520 » | 508 |
| 521 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 509 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 522 ASSERT(pApp); | 510 ASSERT(pApp); |
| 523 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 511 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
| 524 m_aTimer.Add(pTimer); | 512 m_aTimer.Add(pTimer); |
| 525 | 513 |
| 526 pTimer->SetType(0); | 514 pTimer->SetType(0); |
| 527 pTimer->SetRuntime(pRuntime); | 515 pTimer->SetRuntime(pRuntime); |
| 528 pTimer->SetJScript(script); | 516 pTimer->SetJScript(script); |
| 529 pTimer->SetTimeOut(0); | 517 pTimer->SetTimeOut(0); |
| 530 // pTimer->SetStartTime(GetTickCount()); | 518 // pTimer->SetStartTime(GetTickCount()); |
| 531 pTimer->SetJSTimer(dwInterval); | 519 pTimer->SetJSTimer(dwInterval); |
| 532 » | 520 |
| 533 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); | 521 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); |
| 534 » | 522 |
| 535 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); | 523 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); |
| 536 ASSERT(pJS_TimerObj != NULL); | 524 ASSERT(pJS_TimerObj != NULL); |
| 537 » | 525 |
| 538 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 526 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 539 ASSERT(pTimerObj != NULL); | 527 ASSERT(pTimerObj != NULL); |
| 540 » | 528 |
| 541 » pTimerObj->SetTimer(pTimer); | 529 » pTimerObj->SetTimer(pTimer); |
| 542 » | 530 |
| 543 vRet = pRetObj; | 531 vRet = pRetObj; |
| 544 » | 532 |
| 545 return TRUE; | 533 return TRUE; |
| 546 } | 534 } |
| 547 | 535 |
| 548 FX_BOOL app::setTimeOut(OBJ_METHOD_PARAMS) | 536 FX_BOOL app::setTimeOut(OBJ_METHOD_PARAMS) |
| 549 { | 537 { |
| 550 if (params.size() > 2 || params.size() == 0) | 538 if (params.size() > 2 || params.size() == 0) |
| 551 { | 539 { |
| 552 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR);» | 540 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 553 return FALSE; | 541 return FALSE; |
| 554 } | 542 } |
| 555 » | 543 |
| 556 CJS_Context* pContext = (CJS_Context*)cc; | 544 CJS_Context* pContext = (CJS_Context*)cc; |
| 557 ASSERT(pContext != NULL); | 545 ASSERT(pContext != NULL); |
| 558 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 546 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 559 ASSERT(pRuntime != NULL); | 547 ASSERT(pRuntime != NULL); |
| 560 » | 548 |
| 561 CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; | 549 CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; |
| 562 » if (script.IsEmpty()) | 550 » if (script.IsEmpty()) |
| 563 { | 551 { |
| 564 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 552 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
| 565 return TRUE; | 553 return TRUE; |
| 566 } | 554 } |
| 567 » | 555 |
| 568 FX_DWORD dwTimeOut = params.size() > 1 ? (int)params[1] : 1000; | 556 FX_DWORD dwTimeOut = params.size() > 1 ? (int)params[1] : 1000; |
| 569 » | 557 |
| 570 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 558 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 571 ASSERT(pApp); | 559 ASSERT(pApp); |
| 572 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 560 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
| 573 m_aTimer.Add(pTimer); | 561 m_aTimer.Add(pTimer); |
| 574 » | 562 |
| 575 pTimer->SetType(1); | 563 pTimer->SetType(1); |
| 576 pTimer->SetRuntime(pRuntime); | 564 pTimer->SetRuntime(pRuntime); |
| 577 pTimer->SetJScript(script); | 565 pTimer->SetJScript(script); |
| 578 pTimer->SetTimeOut(dwTimeOut); | 566 pTimer->SetTimeOut(dwTimeOut); |
| 579 // pTimer->SetStartTime(GetTickCount()); | 567 // pTimer->SetStartTime(GetTickCount()); |
| 580 // pTimer->SetJSTimer(1000); | 568 // pTimer->SetJSTimer(1000); |
| 581 pTimer->SetJSTimer(dwTimeOut); | 569 pTimer->SetJSTimer(dwTimeOut); |
| 582 » | 570 |
| 583 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); | 571 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); |
| 584 // ASSERT(pRetObj != NULL); | 572 // ASSERT(pRetObj != NULL); |
| 585 » | 573 |
| 586 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); | 574 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); |
| 587 ASSERT(pJS_TimerObj != NULL); | 575 ASSERT(pJS_TimerObj != NULL); |
| 588 » | 576 |
| 589 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 577 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 590 ASSERT(pTimerObj != NULL); | 578 ASSERT(pTimerObj != NULL); |
| 591 » | 579 |
| 592 » pTimerObj->SetTimer(pTimer); | 580 » pTimerObj->SetTimer(pTimer); |
| 593 » | 581 |
| 594 vRet = pRetObj; | 582 vRet = pRetObj; |
| 595 » | 583 |
| 596 return TRUE; | 584 return TRUE; |
| 597 } | 585 } |
| 598 | 586 |
| 599 FX_BOOL app::clearTimeOut(OBJ_METHOD_PARAMS) | 587 FX_BOOL app::clearTimeOut(OBJ_METHOD_PARAMS) |
| 600 { | 588 { |
| 601 CJS_Context* pContext = (CJS_Context*)cc; | 589 CJS_Context* pContext = (CJS_Context*)cc; |
| 602 ASSERT(pContext != NULL); | 590 ASSERT(pContext != NULL); |
| 603 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 591 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 604 ASSERT(pRuntime != NULL); | 592 ASSERT(pRuntime != NULL); |
| 605 » | 593 |
| 606 if (params.size() != 1) | 594 if (params.size() != 1) |
| 607 { | 595 { |
| 608 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR);» | 596 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 609 return FALSE; | 597 return FALSE; |
| 610 } | 598 } |
| 611 » | 599 |
| 612 if (params[0].GetType() == VT_fxobject) | 600 if (params[0].GetType() == VT_fxobject) |
| 613 { | 601 { |
| 614 JSFXObject pObj = (JSFXObject)params[0]; | 602 JSFXObject pObj = (JSFXObject)params[0]; |
| 615 { | 603 { |
| 616 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) | 604 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) |
| 617 { | 605 { |
| 618 if (CJS_Object* pJSObj = (CJS_Object*)params[0]) | 606 if (CJS_Object* pJSObj = (CJS_Object*)params[0]) |
| 619 { | 607 { |
| 620 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) | 608 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) |
| 621 { | 609 { |
| 622 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) | 610 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) |
| 623 { | 611 { |
| 624 pTimer->KillJSTimer(); | 612 pTimer->KillJSTimer(); |
| 625 » » » » » » » | 613 |
| 626 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) | 614 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) |
| 627 { | 615 { |
| 628 if (m_aTimer[i]
== pTimer) | 616 if (m_aTimer[i]
== pTimer) |
| 629 { | 617 { |
| 630 m_aTimer
.RemoveAt(i); | 618 m_aTimer
.RemoveAt(i); |
| 631 break; | 619 break; |
| 632 } | 620 } |
| 633 } | 621 } |
| 634 » » » » » » » | 622 |
| 635 delete pTimer; | 623 delete pTimer; |
| 636 pTimerObj->SetTimer(NULL
); | 624 pTimerObj->SetTimer(NULL
); |
| 637 } | 625 } |
| 638 } | 626 } |
| 639 } | 627 } |
| 640 } | 628 } |
| 641 } | 629 } |
| 642 } | 630 } |
| 643 » | 631 |
| 644 return TRUE; | 632 return TRUE; |
| 645 } | 633 } |
| 646 | 634 |
| 647 FX_BOOL app::clearInterval(OBJ_METHOD_PARAMS) | 635 FX_BOOL app::clearInterval(OBJ_METHOD_PARAMS) |
| 648 { | 636 { |
| 649 CJS_Context* pContext = (CJS_Context*)cc; | 637 CJS_Context* pContext = (CJS_Context*)cc; |
| 650 ASSERT(pContext != NULL); | 638 ASSERT(pContext != NULL); |
| 651 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 639 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 652 ASSERT(pRuntime != NULL); | 640 ASSERT(pRuntime != NULL); |
| 653 | 641 |
| 654 if (params.size() != 1) | 642 if (params.size() != 1) |
| 655 { | 643 { |
| 656 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR);» | 644 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 657 return FALSE; | 645 return FALSE; |
| 658 } | 646 } |
| 659 » | 647 |
| 660 if (params[0].GetType() == VT_fxobject) | 648 if (params[0].GetType() == VT_fxobject) |
| 661 { | 649 { |
| 662 JSFXObject pObj = (JSFXObject)params[0]; | 650 JSFXObject pObj = (JSFXObject)params[0]; |
| 663 { | 651 { |
| 664 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) | 652 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) |
| 665 { | 653 { |
| 666 if (CJS_Object* pJSObj = (CJS_Object*)params[0]) | 654 if (CJS_Object* pJSObj = (CJS_Object*)params[0]) |
| 667 { | 655 { |
| 668 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) | 656 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) |
| 669 { | 657 { |
| 670 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) | 658 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) |
| 671 { | 659 { |
| 672 pTimer->KillJSTimer(); | 660 pTimer->KillJSTimer(); |
| 673 » » » » » » » | 661 |
| 674 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) | 662 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) |
| 675 { | 663 { |
| 676 if (m_aTimer[i]
== pTimer) | 664 if (m_aTimer[i]
== pTimer) |
| 677 { | 665 { |
| 678 m_aTimer
.RemoveAt(i); | 666 m_aTimer
.RemoveAt(i); |
| 679 break; | 667 break; |
| 680 } | 668 } |
| 681 } | 669 } |
| 682 » » » » » » » | 670 |
| 683 delete pTimer; | 671 delete pTimer; |
| 684 pTimerObj->SetTimer(NULL
); | 672 pTimerObj->SetTimer(NULL
); |
| 685 } | 673 } |
| 686 } | 674 } |
| 687 } | 675 } |
| 688 } | 676 } |
| 689 } | 677 } |
| 690 } | 678 } |
| 691 » | 679 |
| 692 return TRUE; | 680 return TRUE; |
| 693 } | 681 } |
| 694 | 682 |
| 695 FX_BOOL app::execMenuItem(OBJ_METHOD_PARAMS) | 683 FX_BOOL app::execMenuItem(OBJ_METHOD_PARAMS) |
| 696 {» | 684 { |
| 697 return FALSE; | 685 return FALSE; |
| 698 } | 686 } |
| 699 | 687 |
| 700 void app::TimerProc(CJS_Timer* pTimer) | 688 void app::TimerProc(CJS_Timer* pTimer) |
| 701 { | 689 { |
| 702 ASSERT(pTimer != NULL); | 690 ASSERT(pTimer != NULL); |
| 703 | 691 |
| 704 switch (pTimer->GetType()) | 692 switch (pTimer->GetType()) |
| 705 { | 693 { |
| 706 case 0: //interval | 694 case 0: //interval |
| 707 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); | 695 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); |
| 708 break; | 696 break; |
| 709 case 1: | 697 case 1: |
| 710 if (pTimer->GetTimeOut() > 0) | 698 if (pTimer->GetTimeOut() > 0) |
| 711 { | 699 { |
| 712 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); | 700 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); |
| 713 pTimer->KillJSTimer(); | 701 pTimer->KillJSTimer(); |
| 714 } | 702 } |
| 715 break; | 703 break; |
| 716 } | 704 } |
| 717 » | 705 |
| 718 } | 706 } |
| 719 | 707 |
| 720 void app::RunJsScript(CJS_Runtime* pRuntime,const CFX_WideString& wsScript) | 708 void app::RunJsScript(CJS_Runtime* pRuntime,const CFX_WideString& wsScript) |
| 721 { | 709 { |
| 722 ASSERT(pRuntime != NULL); | 710 ASSERT(pRuntime != NULL); |
| 723 | 711 |
| 724 if (!pRuntime->IsBlocking()) | 712 if (!pRuntime->IsBlocking()) |
| 725 { | 713 { |
| 726 IFXJS_Context* pContext = pRuntime->NewContext(); | 714 IFXJS_Context* pContext = pRuntime->NewContext(); |
| 727 ASSERT(pContext != NULL); | 715 ASSERT(pContext != NULL); |
| 728 pContext->OnExternal_Exec(); | 716 pContext->OnExternal_Exec(); |
| 729 CFX_WideString wtInfo; | 717 CFX_WideString wtInfo; |
| 730 pContext->RunScript(wsScript,wtInfo); | 718 pContext->RunScript(wsScript,wtInfo); |
| 731 pRuntime->ReleaseContext(pContext); | 719 pRuntime->ReleaseContext(pContext); |
| 732 } | 720 } |
| 733 } | 721 } |
| 734 | 722 |
| 735 FX_BOOL app::goBack(OBJ_METHOD_PARAMS) | 723 FX_BOOL app::goBack(OBJ_METHOD_PARAMS) |
| 736 { | 724 { |
| 737 | 725 // Not supported. |
| 738 | 726 return TRUE; |
| 739 » | |
| 740 » | |
| 741 » | |
| 742 » | |
| 743 » return TRUE; | |
| 744 } | 727 } |
| 745 | 728 |
| 746 FX_BOOL app::goForward(OBJ_METHOD_PARAMS) | 729 FX_BOOL app::goForward(OBJ_METHOD_PARAMS) |
| 747 {» | 730 { |
| 748 | 731 // Not supported. |
| 749 | 732 return TRUE; |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 » return TRUE; | |
| 755 } | 733 } |
| 756 | 734 |
| 757 FX_BOOL app::mailMsg(OBJ_METHOD_PARAMS) | 735 FX_BOOL app::mailMsg(OBJ_METHOD_PARAMS) |
| 758 { | 736 { |
| 759 CJS_Context* pContext = (CJS_Context*)cc; | 737 CJS_Context* pContext = (CJS_Context*)cc; |
| 760 ASSERT(pContext != NULL); | 738 ASSERT(pContext != NULL); |
| 761 | 739 |
| 762 v8::Isolate* isolate = GetIsolate(cc); | 740 v8::Isolate* isolate = GetIsolate(cc); |
| 763 | 741 |
| 764 FX_BOOL bUI = TRUE; | 742 FX_BOOL bUI = TRUE; |
| 765 CFX_WideString cTo = L""; | 743 CFX_WideString cTo = L""; |
| 766 CFX_WideString cCc = L""; | 744 CFX_WideString cCc = L""; |
| 767 CFX_WideString cBcc = L""; | 745 CFX_WideString cBcc = L""; |
| 768 CFX_WideString cSubject = L""; | 746 CFX_WideString cSubject = L""; |
| 769 CFX_WideString cMsg = L""; | 747 CFX_WideString cMsg = L""; |
| 770 if(params.size() < 2) | 748 if(params.size() < 2) |
| 771 return FALSE; | 749 return FALSE; |
| 772 | 750 |
| 773 bUI = params.size()>=1?(int)params[0]:TRUE; | 751 bUI = params.size()>=1?(int)params[0]:TRUE; |
| 774 cTo = params.size()>=2?(const wchar_t*)(FX_LPCWSTR)params[1].operator CF
X_WideString():L""; | 752 cTo = params.size()>=2?(const wchar_t*)(FX_LPCWSTR)params[1].operator CF
X_WideString():L""; |
| 775 cCc = params.size()>=3?(const wchar_t*)(FX_LPCWSTR)params[2].operator CF
X_WideString():L""; | 753 cCc = params.size()>=3?(const wchar_t*)(FX_LPCWSTR)params[2].operator CF
X_WideString():L""; |
| 776 cBcc = params.size()>=4?(const wchar_t*)(FX_LPCWSTR)params[3].operator C
FX_WideString():L""; | 754 cBcc = params.size()>=4?(const wchar_t*)(FX_LPCWSTR)params[3].operator C
FX_WideString():L""; |
| 777 cSubject = params.size()>=5?(const wchar_t*)(FX_LPCWSTR)params[4].operat
or CFX_WideString():L""; | 755 cSubject = params.size()>=5?(const wchar_t*)(FX_LPCWSTR)params[4].operat
or CFX_WideString():L""; |
| 778 » cMsg = params.size()>=6?(const wchar_t*)(FX_LPCWSTR)params[5].operator C
FX_WideString():L"";» » | 756 » cMsg = params.size()>=6?(const wchar_t*)(FX_LPCWSTR)params[5].operator C
FX_WideString():L""; |
| 779 | 757 |
| 780 | 758 |
| 781 if (params[0].GetType() == VT_object) | 759 if (params[0].GetType() == VT_object) |
| 782 { | 760 { |
| 783 JSObject pObj = (JSObject)params[0]; | 761 JSObject pObj = (JSObject)params[0]; |
| 784 | 762 |
| 785 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); | 763 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); |
| 786 bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); | 764 bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); |
| 787 | 765 |
| 788 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); | 766 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); |
| 789 cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 767 cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); |
| 790 | 768 |
| 791 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); | 769 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); |
| 792 cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 770 cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); |
| 793 | 771 |
| 794 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); | 772 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); |
| 795 cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 773 cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); |
| 796 | 774 |
| 797 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); | 775 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); |
| 798 cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); | 776 cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); |
| 799 | 777 |
| 800 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); | 778 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); |
| 801 cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 779 cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); |
| 802 } | 780 } |
| 803 » | 781 |
| 804 » | 782 |
| 805 | 783 |
| 806 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 784 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 807 ASSERT(pRuntime != NULL); | 785 ASSERT(pRuntime != NULL); |
| 808 | 786 |
| 809 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 787 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 810 ASSERT(pApp != NULL); | 788 ASSERT(pApp != NULL); |
| 811 | 789 |
| 812 pRuntime->BeginBlock(); | 790 pRuntime->BeginBlock(); |
| 813 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); | 791 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); |
| 814 ////////////////////////////////////////////////////////////////////////
/////////////////////// | 792 ////////////////////////////////////////////////////////////////////////
/////////////////////// |
| 815 pRuntime->EndBlock(); | 793 pRuntime->EndBlock(); |
| 816 | 794 |
| 817 //return bRet; | 795 //return bRet; |
| 818 return FALSE; | 796 return FALSE; |
| 819 } | 797 } |
| 820 | 798 |
| 821 FX_BOOL app::launchURL(OBJ_METHOD_PARAMS) | 799 FX_BOOL app::launchURL(OBJ_METHOD_PARAMS) |
| 822 { | 800 { |
| 823 » if (IsSafeMode(cc)) return TRUE; | 801 // Unsafe, not supported. |
| 824 | 802 return TRUE; |
| 825 » CJS_Context* pContext = (CJS_Context*)cc; | |
| 826 » ASSERT(pContext != NULL); | |
| 827 | |
| 828 » | |
| 829 | |
| 830 | |
| 831 » CFX_WideString swURL = params[0].operator CFX_WideString(); | |
| 832 | |
| 833 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 834 » ASSERT(pRuntime != NULL); | |
| 835 | |
| 836 » pRuntime->BeginBlock(); | |
| 837 //» FX_BOOL bRet = pApp->OpenURL(swURL); | |
| 838 » pRuntime->EndBlock(); | |
| 839 | |
| 840 //» return bRet; | |
| 841 » return FALSE; | |
| 842 } | 803 } |
| 843 | 804 |
| 844 FX_BOOL app::runtimeHighlight(OBJ_PROP_PARAMS) | 805 FX_BOOL app::runtimeHighlight(OBJ_PROP_PARAMS) |
| 845 { | 806 { |
| 846 if (vp.IsSetting()) | 807 if (vp.IsSetting()) |
| 847 { | 808 { |
| 848 vp>>m_bRuntimeHighLight; | 809 vp>>m_bRuntimeHighLight; |
| 849 } | 810 } |
| 850 else | 811 else |
| 851 { | 812 { |
| 852 vp<<m_bRuntimeHighLight; | 813 vp<<m_bRuntimeHighLight; |
| 853 } | 814 } |
| 854 | 815 |
| 855 return TRUE; | 816 return TRUE; |
| 856 } | 817 } |
| 857 | 818 |
| 858 FX_BOOL app::fullscreen(OBJ_PROP_PARAMS) | 819 FX_BOOL app::fullscreen(OBJ_PROP_PARAMS) |
| 859 { | 820 { |
| 860 return FALSE; | 821 return FALSE; |
| 861 } | 822 } |
| 862 | 823 |
| 863 FX_BOOL app::popUpMenu(OBJ_METHOD_PARAMS) | 824 FX_BOOL app::popUpMenu(OBJ_METHOD_PARAMS) |
| 864 { | 825 { |
| 865 return FALSE; | 826 return FALSE; |
| 866 } | 827 } |
| 867 | 828 |
| 868 | 829 |
| 869 FX_BOOL app::browseForDoc(OBJ_METHOD_PARAMS) | 830 FX_BOOL app::browseForDoc(OBJ_METHOD_PARAMS) |
| 870 { | 831 { |
| 871 » //This method may trigger a "file save" dialog,while enable user to save
contents of the document. | 832 // Unsafe, not supported. |
| 872 » //Such action is considered to be unsafe. | 833 return TRUE; |
| 873 » if (IsSafeMode(cc)) return TRUE; | |
| 874 | |
| 875 » v8::Isolate* isolate = GetIsolate(cc); | |
| 876 | |
| 877 » bool bSave = false; | |
| 878 » CFX_ByteString cFilenameInit = CFX_ByteString(); | |
| 879 » CFX_ByteString cFSInit = CFX_ByteString(); | |
| 880 | |
| 881 » if(params.size()>0 && (params[0].GetType() == VT_object)) | |
| 882 » { | |
| 883 » » JSObject pObj = (JSObject )params[0]; | |
| 884 | |
| 885 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bSave"); | |
| 886 » » » bSave = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pV
alue)); | |
| 887 » » | |
| 888 » » pValue = JS_GetObjectElement(isolate, pObj,L"cFilenameInit"); | |
| 889 » » { | |
| 890 » » » CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE(
pValue)); | |
| 891 » » » cFilenameInit = t.operator CFX_ByteString(); | |
| 892 » » } | |
| 893 » » | |
| 894 » » pValue = JS_GetObjectElement(isolate,pObj,L"cFSInit"); | |
| 895 » » { | |
| 896 » » » CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE(
pValue)); | |
| 897 » » » cFSInit = t.operator CFX_ByteString(); | |
| 898 » » } | |
| 899 » } | |
| 900 » else | |
| 901 » { | |
| 902 » » if(params.size() >= 1) | |
| 903 » » { | |
| 904 » » » bSave = (bool)params[0]; | |
| 905 » » } | |
| 906 » » if(params.size() >= 2) | |
| 907 » » { | |
| 908 » » » CJS_Value t = params[1]; | |
| 909 » » » cFilenameInit = t.operator CFX_ByteString(); | |
| 910 » » } | |
| 911 » » if(params.size() >= 3) | |
| 912 » » { | |
| 913 » » » CJS_Value t = params[2]; | |
| 914 » » » cFSInit = t.operator CFX_ByteString(); | |
| 915 » » } | |
| 916 » } | |
| 917 » CJS_Context* pContext = (CJS_Context *)cc; | |
| 918 » ASSERT(pContext != NULL); | |
| 919 » | |
| 920 » CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | |
| 921 » ASSERT(pApp != NULL); | |
| 922 | |
| 923 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 924 » ASSERT(pRuntime != NULL); | |
| 925 | |
| 926 » CFX_WideString wsFileNameInit = CFX_WideString::FromLocal(cFilenameInit)
; | |
| 927 » CFX_WideString wsFSInit = CFX_WideString::FromLocal(cFSInit); | |
| 928 » CFX_WideString wsFilePath = pApp->JS_appbrowseForDoc(bSave, wsFileNameIn
it); | |
| 929 » if(wsFilePath.IsEmpty()) | |
| 930 » » return FALSE; | |
| 931 | |
| 932 » JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1); | |
| 933 | |
| 934 » JS_PutObjectString(isolate,pRetObj, L"cPath", SysPathToPDFPath(wsFilePat
h));» | |
| 935 » JS_PutObjectString(isolate,pRetObj, L"cURL", SysPathToPDFPath(wsFilePath
)); | |
| 936 | |
| 937 » if (!cFSInit.IsEmpty()) | |
| 938 » { | |
| 939 » » JS_PutObjectString(isolate,pRetObj, L"cFS", CFX_WideString::From
Local(cFSInit.GetBuffer(cFSInit.GetLength()))); | |
| 940 » } | |
| 941 » else | |
| 942 » { | |
| 943 » » JS_PutObjectString(isolate,pRetObj, L"cFS", CFX_WideString::From
Local("DOS")); | |
| 944 » } | |
| 945 » | |
| 946 » vRet =» pRetObj; | |
| 947 | |
| 948 » return TRUE; | |
| 949 } | 834 } |
| 950 | 835 |
| 951 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) | 836 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) |
| 952 { | 837 { |
| 953 CFX_WideString sRet = L"/"; | 838 CFX_WideString sRet = L"/"; |
| 954 » | 839 |
| 955 for (int i=0,sz=sOldPath.GetLength(); i<sz; i++) | 840 for (int i=0,sz=sOldPath.GetLength(); i<sz; i++) |
| 956 { | 841 { |
| 957 wchar_t c = sOldPath.GetAt(i); | 842 wchar_t c = sOldPath.GetAt(i); |
| 958 if (c == L':') | 843 if (c == L':') |
| 959 { | 844 { |
| 960 } | 845 } |
| 961 else | 846 else |
| 962 { | 847 { |
| 963 if (c == L'\\') | 848 if (c == L'\\') |
| 964 { | 849 { |
| 965 sRet += L"/"; | 850 sRet += L"/"; |
| 966 } | 851 } |
| 967 else | 852 else |
| 968 { | 853 { |
| 969 sRet += c; | 854 sRet += c; |
| 970 } | 855 } |
| 971 } | 856 } |
| 972 } | 857 } |
| 973 » | 858 |
| 974 return sRet; | 859 return sRet; |
| 975 } | 860 } |
| 976 | 861 |
| 977 CFX_WideString app::PDFPathToSysPath(const CFX_WideString& sOldPath) | |
| 978 { | |
| 979 //strLPath = "D:\temporay.fdf"; | |
| 980 CFX_WideString strOPath = sOldPath; | |
| 981 strOPath.TrimLeft(); | |
| 982 strOPath.TrimRight(); | |
| 983 | |
| 984 if (strOPath.GetAt(0) == L'/' && strOPath.GetAt(2) == L'/') | |
| 985 { | |
| 986 wchar_t c_Drive = strOPath.GetAt(1); | |
| 987 if ((c_Drive >= L'a' && c_Drive <= L'z' )||( c_Drive >= L'A' &&
c_Drive <= L'Z')) | |
| 988 { | |
| 989 strOPath.Replace(L"/",L"\\"); | |
| 990 //strOPath.SetAt(0,''); | |
| 991 strOPath.Insert(2,':'); | |
| 992 strOPath.Delete(0); | |
| 993 } | |
| 994 } | |
| 995 | |
| 996 return strOPath; | |
| 997 } | |
| 998 | |
| 999 CFX_WideString app::RelativePathToSysPath(const CFX_WideString& sOldPath, const
CFX_WideString& sFilePath) | |
| 1000 { | |
| 1001 // if (!PathIsRelative(sOldPath)) return sOldPath; | |
| 1002 | |
| 1003 int nSplit = 0; | |
| 1004 for (int i=sFilePath.GetLength()-1; i>=0; i--) | |
| 1005 { | |
| 1006 if (sFilePath[i] == '\\' || sFilePath[i] == '/') | |
| 1007 { | |
| 1008 nSplit = i; | |
| 1009 break; | |
| 1010 } | |
| 1011 } | |
| 1012 | |
| 1013 return sFilePath.Left(nSplit+1) + sOldPath; | |
| 1014 } | |
| 1015 | |
| 1016 FX_BOOL app::newDoc(OBJ_METHOD_PARAMS) | 862 FX_BOOL app::newDoc(OBJ_METHOD_PARAMS) |
| 1017 { | 863 { |
| 1018 return FALSE; | 864 return FALSE; |
| 1019 } | 865 } |
| 1020 | 866 |
| 1021 FX_BOOL app::openDoc(OBJ_METHOD_PARAMS) | 867 FX_BOOL app::openDoc(OBJ_METHOD_PARAMS) |
| 1022 { | 868 { |
| 1023 return FALSE; | 869 return FALSE; |
| 1024 } | 870 } |
| 1025 | 871 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 | 951 |
| 1106 FX_BOOL app::media(OBJ_PROP_PARAMS) | 952 FX_BOOL app::media(OBJ_PROP_PARAMS) |
| 1107 { | 953 { |
| 1108 return FALSE; | 954 return FALSE; |
| 1109 } | 955 } |
| 1110 | 956 |
| 1111 FX_BOOL app::execDialog(OBJ_METHOD_PARAMS) | 957 FX_BOOL app::execDialog(OBJ_METHOD_PARAMS) |
| 1112 { | 958 { |
| 1113 return TRUE; | 959 return TRUE; |
| 1114 } | 960 } |
| 1115 | |
| OLD | NEW |