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 "JS_Context.h" | 7 #include "JS_Context.h" |
8 | 8 |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "JS_EventHandler.h" | 10 #include "JS_EventHandler.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 m_bBusy = TRUE; | 46 m_bBusy = TRUE; |
47 | 47 |
48 ASSERT(m_pEventHandler->IsValid()); | 48 ASSERT(m_pEventHandler->IsValid()); |
49 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), | 49 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), |
50 m_pEventHandler->EventType()); | 50 m_pEventHandler->EventType()); |
51 if (!m_pRuntime->AddEventToSet(event)) { | 51 if (!m_pRuntime->AddEventToSet(event)) { |
52 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); | 52 info = JSGetStringFromID(this, IDS_STRING_JSEVENT); |
53 return FALSE; | 53 return FALSE; |
54 } | 54 } |
55 | 55 |
56 FXJSErr error = {NULL, NULL, 0}; | 56 CFX_WideString sErrorMessage; |
57 int nRet = 0; | 57 int nRet = 0; |
58 if (script.GetLength() > 0) { | 58 if (script.GetLength() > 0) { |
59 nRet = FXJS_Execute(m_pRuntime->GetIsolate(), this, script.c_str(), | 59 nRet = m_pRuntime->Execute(this, script.c_str(), script.GetLength(), |
60 script.GetLength(), &error); | 60 sErrorMessage); |
61 } | 61 } |
62 | 62 |
63 if (nRet < 0) { | 63 if (nRet < 0) { |
64 CFX_WideString sLine; | 64 info += sErrorMessage; |
65 sLine.Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline, | |
66 error.message); | |
67 info += sLine; | |
68 } else { | 65 } else { |
69 info = JSGetStringFromID(this, IDS_STRING_RUN); | 66 info = JSGetStringFromID(this, IDS_STRING_RUN); |
70 } | 67 } |
71 | 68 |
72 m_pRuntime->RemoveEventFromSet(event); | 69 m_pRuntime->RemoveEventFromSet(event); |
73 m_pEventHandler->Destroy(); | 70 m_pEventHandler->Destroy(); |
74 m_bBusy = FALSE; | 71 m_bBusy = FALSE; |
75 | 72 |
76 return nRet >= 0; | 73 return nRet >= 0; |
77 } | 74 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 275 } |
279 | 276 |
280 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { | 277 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { |
281 m_pEventHandler->OnBatchExec(pTarget); | 278 m_pEventHandler->OnBatchExec(pTarget); |
282 } | 279 } |
283 | 280 |
284 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, | 281 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, |
285 const CFX_WideString& strTargetName) { | 282 const CFX_WideString& strTargetName) { |
286 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); | 283 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); |
287 } | 284 } |
OLD | NEW |