Cleanup: Do not check pointers before deleting them, part 2.
[pdfium.git] / fpdfsdk / src / javascript / JS_Context.cpp
index 21acf59..72be34d 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "../../include/javascript/JavaScript.h"\r
-#include "../../include/javascript/IJavaScript.h"\r
-//#include "../../include/javascript/JS_ResMgr.h"\r
-#include "../../include/javascript/JS_Context.h"\r
-#include "../../include/javascript/JS_EventHandler.h"\r
-#include "../../include/javascript/JS_Runtime.h"\r
-#include "../../include/javascript/resource.h"\r
-\r
-/* -------------------------- CJS_Context -------------------------- */\r
-\r
-CJS_Context::CJS_Context(CJS_Runtime* pRuntime) :      \r
-       m_pRuntime(pRuntime),\r
-       m_bBusy(FALSE),\r
-       m_bMsgBoxEnable(TRUE)\r
-{\r
-       m_pEventHandler = new CJS_EventHandler(this);\r
-}\r
-\r
-CJS_Context::~CJS_Context(void)\r
-{\r
-       if (m_pEventHandler)\r
-       {\r
-               delete m_pEventHandler;\r
-               m_pEventHandler = NULL;\r
-       }\r
-}\r
-\r
-CPDFSDK_Document* CJS_Context::GetReaderDocument()\r
-{\r
-       ASSERT(m_pRuntime != NULL);\r
-\r
-       return m_pRuntime->GetReaderDocument();\r
-}\r
-\r
-CPDFDoc_Environment* CJS_Context::GetReaderApp()\r
-{\r
-       ASSERT(m_pRuntime != NULL);\r
-       \r
-       return m_pRuntime->GetReaderApp();\r
-}\r
-\r
-FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info)\r
-{\r
-       if (m_bBusy)\r
-       {               \r
-               info = JSGetStringFromID(this, IDS_STRING_JSBUSY);\r
-               return FALSE;\r
-       }       \r
-\r
-       m_bBusy = TRUE;\r
-\r
-       ASSERT(m_pRuntime != NULL);\r
-       ASSERT(m_pEventHandler != NULL);\r
-       ASSERT(m_pEventHandler->IsValid());\r
-\r
-       if (!m_pRuntime->AddEventToLoop(m_pEventHandler->TargetName(), m_pEventHandler->EventType()))\r
-       {\r
-               info = JSGetStringFromID(this, IDS_STRING_JSEVENT);\r
-               return FALSE;\r
-       }\r
-\r
-       FXJSErr error ={NULL,NULL, 0};\r
-       int nRet = 0;   \r
-\r
-       try\r
-       {       \r
-               if (script.GetLength() > 0)\r
-               {\r
-                       if (nMode == 0)\r
-                       {               \r
-                               nRet = JS_Execute(*m_pRuntime, this, script, script.GetLength(), &error);\r
-                       }\r
-                       else\r
-                       {\r
-                               nRet = JS_Parse(*m_pRuntime, this, script, script.GetLength(), &error);\r
-                       }\r
-               }\r
-\r
-               if (nRet < 0)\r
-               {\r
-                       CFX_WideString sLine;\r
-                       sLine.Format((FX_LPCWSTR)L"[ Line: %05d { %s } ] : %s",error.linnum-1,error.srcline,error.message);\r
-\r
-//                     TRACE(L"/* -------------- JS Error -------------- */\n");\r
-//                     TRACE(sLine);\r
-//                     TRACE(L"\n");\r
-                       //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(error.message);\r
-                       info += sLine;\r
-               }\r
-               else\r
-               {\r
-                       info = JSGetStringFromID(this, IDS_STRING_RUN);\r
-               }               \r
-\r
-       }\r
-       catch (...)\r
-       {\r
-               info = JSGetStringFromID(this, IDS_STRING_UNHANDLED);\r
-               nRet = -1;\r
-       }\r
-\r
-       m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), m_pEventHandler->EventType());\r
-\r
-       m_pEventHandler->Destroy();\r
-       m_bBusy = FALSE;        \r
-\r
-       return nRet >= 0;\r
-}\r
-\r
-FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, CFX_WideString& info)\r
-{\r
-       v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());\r
-       HandleScope handle_scope(m_pRuntime->GetIsolate());\r
-       v8::Local<v8::Context> context = m_pRuntime->NewJSContext();\r
-       v8::Context::Scope context_scope(context);\r
-\r
-       return DoJob(0, script, info);\r
-}\r
-\r
-FX_BOOL CJS_Context::Compile(const CFX_WideString& script, CFX_WideString& info)\r
-{\r
-       v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());\r
-       HandleScope handle_scope(m_pRuntime->GetIsolate());\r
-       v8::Local<v8::Context> context = m_pRuntime->NewJSContext();\r
-       v8::Context::Scope context_scope(context);\r
-\r
-       return DoJob(1, script, info);\r
-}\r
-\r
-void CJS_Context::OnApp_Init()\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnApp_Init();\r
-}\r
-\r
-void CJS_Context::OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString &strTargetName)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_Open(pDoc,strTargetName);\r
-}\r
-\r
-void CJS_Context::OnDoc_WillPrint(CPDFSDK_Document* pDoc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_WillPrint(pDoc);\r
-}\r
-\r
-void CJS_Context::OnDoc_DidPrint(CPDFSDK_Document* pDoc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_DidPrint(pDoc);\r
-}\r
-\r
-void CJS_Context::OnDoc_WillSave(CPDFSDK_Document* pDoc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_WillSave(pDoc);\r
-}\r
-\r
-void CJS_Context::OnDoc_DidSave(CPDFSDK_Document* pDoc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_DidSave(pDoc);\r
-}\r
-\r
-void CJS_Context::OnDoc_WillClose(CPDFSDK_Document* pDoc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnDoc_WillClose(pDoc);\r
-}\r
-\r
-void CJS_Context::OnPage_Open(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnPage_Open(pTarget);\r
-}\r
-\r
-void CJS_Context::OnPage_Close(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnPage_Close(pTarget);\r
-}\r
-\r
-void CJS_Context::OnPage_InView(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnPage_InView(pTarget);\r
-}\r
-\r
-void CJS_Context::OnPage_OutView(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnPage_OutView(pTarget);\r
-}\r
-\r
-void CJS_Context::OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget);\r
-}\r
-\r
-void CJS_Context::OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget);\r
-}\r
-\r
-void CJS_Context::OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget);\r
-}\r
-\r
-void CJS_Context::OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget);\r
-}\r
-\r
-void CJS_Context::OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value);\r
-}\r
-\r
-void CJS_Context::OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value);\r
-}\r
-\r
-void CJS_Context::OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Calculate(pSource, pTarget, Value, bRc);\r
-}\r
-\r
-void CJS_Context::OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Format(nCommitKey, pTarget, Value, bWillCommit);\r
-}\r
-\r
-\r
-void CJS_Context::OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx,\r
-                                                                       FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart,\r
-                                                                       FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value,\r
-                                                                       FX_BOOL bWillCommit, FX_BOOL bFieldFull, FX_BOOL& bRc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Keystroke(nCommitKey, strChange, strChangeEx, bKeyDown,\r
-               bModifier, nSelEnd, nSelStart, bShift, pTarget, Value, bWillCommit, bFieldFull, bRc);\r
-}\r
-\r
-void CJS_Context::OnField_Validate(CFX_WideString& strChange,const CFX_WideString& strChangeEx,\r
-                                                                  FX_BOOL bKeyDown, FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget,\r
-                                                                  CFX_WideString& Value, FX_BOOL& bRc)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier, bShift, pTarget, Value, bRc);\r
-}\r
-\r
-void CJS_Context::OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen);\r
-}\r
-\r
-void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnBookmark_MouseUp(pBookMark);\r
-}\r
-\r
-void CJS_Context::OnLink_MouseUp(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnLink_MouseUp(pTarget);\r
-}\r
-\r
-void CJS_Context::OnConsole_Exec()\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnConsole_Exec();\r
-}\r
-\r
-void CJS_Context::OnExternal_Exec()\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnExternal_Exec();\r
-}\r
-\r
-void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);        \r
-       m_pEventHandler->OnBatchExec(pTarget);\r
-}\r
-\r
-void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,const CFX_WideString& strTargetName)\r
-{\r
-       ASSERT(m_pEventHandler != NULL);\r
-       m_pEventHandler->OnMenu_Exec(pTarget, strTargetName);\r
-}\r
-\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../include/javascript/JavaScript.h"
+#include "../../include/javascript/IJavaScript.h"
+//#include "../../include/javascript/JS_ResMgr.h"
+#include "../../include/javascript/JS_Context.h"
+#include "../../include/javascript/JS_EventHandler.h"
+#include "../../include/javascript/JS_Runtime.h"
+#include "../../include/javascript/resource.h"
+
+/* -------------------------- CJS_Context -------------------------- */
+
+CJS_Context::CJS_Context(CJS_Runtime* pRuntime) :
+       m_pRuntime(pRuntime),
+       m_bBusy(FALSE),
+       m_bMsgBoxEnable(TRUE)
+{
+       m_pEventHandler = new CJS_EventHandler(this);
+}
+
+CJS_Context::~CJS_Context(void)
+{
+    delete m_pEventHandler;
+}
+
+CPDFSDK_Document* CJS_Context::GetReaderDocument()
+{
+       ASSERT(m_pRuntime != NULL);
+
+       return m_pRuntime->GetReaderDocument();
+}
+
+CPDFDoc_Environment* CJS_Context::GetReaderApp()
+{
+       ASSERT(m_pRuntime != NULL);
+
+       return m_pRuntime->GetReaderApp();
+}
+
+FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info)
+{
+       if (m_bBusy)
+       {
+               info = JSGetStringFromID(this, IDS_STRING_JSBUSY);
+               return FALSE;
+       }
+
+       m_bBusy = TRUE;
+
+       ASSERT(m_pRuntime != NULL);
+       ASSERT(m_pEventHandler != NULL);
+       ASSERT(m_pEventHandler->IsValid());
+
+       if (!m_pRuntime->AddEventToLoop(m_pEventHandler->TargetName(), m_pEventHandler->EventType()))
+       {
+               info = JSGetStringFromID(this, IDS_STRING_JSEVENT);
+               return FALSE;
+       }
+
+       FXJSErr error ={NULL,NULL, 0};
+       int nRet = 0;
+
+       if (script.GetLength() > 0)
+       {
+               if (nMode == 0)
+               {
+                       nRet = JS_Execute(*m_pRuntime, this, script.c_str(), script.GetLength(), &error);
+               }
+               else
+               {
+                       nRet = JS_Parse(*m_pRuntime, this, script.c_str(), script.GetLength(), &error);
+               }
+       }
+
+       if (nRet < 0)
+       {
+               CFX_WideString sLine;
+               sLine.Format(L"[ Line: %05d { %s } ] : %s",error.linnum-1,error.srcline,error.message);
+
+//                     TRACE(L"/* -------------- JS Error -------------- */\n");
+//                     TRACE(sLine);
+//                     TRACE(L"\n");
+               //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(error.message);
+               info += sLine;
+       }
+       else
+       {
+               info = JSGetStringFromID(this, IDS_STRING_RUN);
+       }
+
+       m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), m_pEventHandler->EventType());
+
+       m_pEventHandler->Destroy();
+       m_bBusy = FALSE;
+
+       return nRet >= 0;
+}
+
+FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, CFX_WideString& info)
+{
+       v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
+       v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
+       v8::Local<v8::Context> context = m_pRuntime->NewJSContext();
+       v8::Context::Scope context_scope(context);
+
+       return DoJob(0, script, info);
+}
+
+FX_BOOL CJS_Context::Compile(const CFX_WideString& script, CFX_WideString& info)
+{
+       v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
+       v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
+       v8::Local<v8::Context> context = m_pRuntime->NewJSContext();
+       v8::Context::Scope context_scope(context);
+
+       return DoJob(1, script, info);
+}
+
+void CJS_Context::OnApp_Init()
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnApp_Init();
+}
+
+void CJS_Context::OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString &strTargetName)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_Open(pDoc,strTargetName);
+}
+
+void CJS_Context::OnDoc_WillPrint(CPDFSDK_Document* pDoc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_WillPrint(pDoc);
+}
+
+void CJS_Context::OnDoc_DidPrint(CPDFSDK_Document* pDoc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_DidPrint(pDoc);
+}
+
+void CJS_Context::OnDoc_WillSave(CPDFSDK_Document* pDoc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_WillSave(pDoc);
+}
+
+void CJS_Context::OnDoc_DidSave(CPDFSDK_Document* pDoc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_DidSave(pDoc);
+}
+
+void CJS_Context::OnDoc_WillClose(CPDFSDK_Document* pDoc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnDoc_WillClose(pDoc);
+}
+
+void CJS_Context::OnPage_Open(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnPage_Open(pTarget);
+}
+
+void CJS_Context::OnPage_Close(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnPage_Close(pTarget);
+}
+
+void CJS_Context::OnPage_InView(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnPage_InView(pTarget);
+}
+
+void CJS_Context::OnPage_OutView(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnPage_OutView(pTarget);
+}
+
+void CJS_Context::OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget);
+}
+
+void CJS_Context::OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget);
+}
+
+void CJS_Context::OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget);
+}
+
+void CJS_Context::OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget);
+}
+
+void CJS_Context::OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value);
+}
+
+void CJS_Context::OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value);
+}
+
+void CJS_Context::OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_Calculate(pSource, pTarget, Value, bRc);
+}
+
+void CJS_Context::OnField_Format(CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit)
+{
+    m_pEventHandler->OnField_Format(pTarget, Value, bWillCommit);
+}
+
+
+void CJS_Context::OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx,
+                                                                       FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart,
+                                                                       FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value,
+                                                                       FX_BOOL bWillCommit, FX_BOOL bFieldFull, FX_BOOL& bRc)
+{
+    m_pEventHandler->OnField_Keystroke(
+        strChange, strChangeEx, bKeyDown, bModifier, nSelEnd, nSelStart,
+        bShift, pTarget, Value, bWillCommit, bFieldFull, bRc);
+}
+
+void CJS_Context::OnField_Validate(CFX_WideString& strChange,const CFX_WideString& strChangeEx,
+                                                                  FX_BOOL bKeyDown, FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget,
+                                                                  CFX_WideString& Value, FX_BOOL& bRc)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier, bShift, pTarget, Value, bRc);
+}
+
+void CJS_Context::OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen);
+}
+
+void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnBookmark_MouseUp(pBookMark);
+}
+
+void CJS_Context::OnLink_MouseUp(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnLink_MouseUp(pTarget);
+}
+
+void CJS_Context::OnConsole_Exec()
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnConsole_Exec();
+}
+
+void CJS_Context::OnExternal_Exec()
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnExternal_Exec();
+}
+
+void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnBatchExec(pTarget);
+}
+
+void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,const CFX_WideString& strTargetName)
+{
+       ASSERT(m_pEventHandler != NULL);
+       m_pEventHandler->OnMenu_Exec(pTarget, strTargetName);
+}
+