| 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_ResMgr.h" | 9 //#include "../../include/javascript/JS_ResMgr.h" |
| 10 #include "../../include/javascript/JS_Context.h" | 10 #include "../../include/javascript/JS_Context.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 if (!m_pRuntime->AddEventToLoop(m_pEventHandler->TargetName(), m_pEventH
andler->EventType())) | 62 if (!m_pRuntime->AddEventToLoop(m_pEventHandler->TargetName(), m_pEventH
andler->EventType())) |
| 63 { | 63 { |
| 64 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); | 64 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); |
| 65 return FALSE; | 65 return FALSE; |
| 66 } | 66 } |
| 67 | 67 |
| 68 FXJSErr error ={NULL,NULL, 0}; | 68 FXJSErr error ={NULL,NULL, 0}; |
| 69 int nRet = 0; | 69 int nRet = 0; |
| 70 | 70 |
| 71 » try | 71 » if (script.GetLength() > 0) |
| 72 » {» | 72 » { |
| 73 » » if (script.GetLength() > 0) | 73 » » if (nMode == 0) |
| 74 { | 74 { |
| 75 » » » if (nMode == 0) | 75 » » » nRet = JS_Execute(*m_pRuntime, this, script, script.GetL
ength(), &error); |
| 76 » » » {» » | |
| 77 » » » » nRet = JS_Execute(*m_pRuntime, this, script, scr
ipt.GetLength(), &error); | |
| 78 » » » } | |
| 79 » » » else | |
| 80 » » » { | |
| 81 » » » » nRet = JS_Parse(*m_pRuntime, this, script, scrip
t.GetLength(), &error); | |
| 82 » » » } | |
| 83 } | 76 } |
| 77 else |
| 78 { |
| 79 nRet = JS_Parse(*m_pRuntime, this, script, script.GetLen
gth(), &error); |
| 80 } |
| 81 } |
| 84 | 82 |
| 85 » » if (nRet < 0) | 83 » if (nRet < 0) |
| 86 » » { | 84 » { |
| 87 » » » CFX_WideString sLine; | 85 » » CFX_WideString sLine; |
| 88 » » » sLine.Format((FX_LPCWSTR)L"[ Line: %05d { %s } ] : %s",e
rror.linnum-1,error.srcline,error.message); | 86 » » sLine.Format((FX_LPCWSTR)L"[ Line: %05d { %s } ] : %s",error.lin
num-1,error.srcline,error.message); |
| 89 | 87 |
| 90 // TRACE(L"/* -------------- JS Error -------------- */\n")
; | 88 // TRACE(L"/* -------------- JS Error -------------- */\n")
; |
| 91 // TRACE(sLine); | 89 // TRACE(sLine); |
| 92 // TRACE(L"\n"); | 90 // TRACE(L"\n"); |
| 93 » » » //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(err
or.message); | 91 » » //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(error.messa
ge); |
| 94 » » » info += sLine; | 92 » » info += sLine; |
| 95 » » } | |
| 96 » » else | |
| 97 » » { | |
| 98 » » » info = JSGetStringFromID(this, IDS_STRING_RUN); | |
| 99 » » }» » | |
| 100 | |
| 101 } | 93 } |
| 102 » catch (...) | 94 » else |
| 103 { | 95 { |
| 104 » » info = JSGetStringFromID(this, IDS_STRING_UNHANDLED); | 96 » » info = JSGetStringFromID(this, IDS_STRING_RUN); |
| 105 » » nRet = -1; | |
| 106 } | 97 } |
| 107 | 98 |
| 108 m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), m_pEventHan
dler->EventType()); | 99 m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), m_pEventHan
dler->EventType()); |
| 109 | 100 |
| 110 m_pEventHandler->Destroy(); | 101 m_pEventHandler->Destroy(); |
| 111 m_bBusy = FALSE; | 102 m_bBusy = FALSE; |
| 112 | 103 |
| 113 return nRet >= 0; | 104 return nRet >= 0; |
| 114 } | 105 } |
| 115 | 106 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 ASSERT(m_pEventHandler != NULL); | 346 ASSERT(m_pEventHandler != NULL); |
| 356 m_pEventHandler->OnBatchExec(pTarget); | 347 m_pEventHandler->OnBatchExec(pTarget); |
| 357 } | 348 } |
| 358 | 349 |
| 359 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,const CFX_WideString& st
rTargetName) | 350 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,const CFX_WideString& st
rTargetName) |
| 360 { | 351 { |
| 361 ASSERT(m_pEventHandler != NULL); | 352 ASSERT(m_pEventHandler != NULL); |
| 362 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); | 353 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); |
| 363 } | 354 } |
| 364 | 355 |
| OLD | NEW |