1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_actionhandler.h"
10 #include "../include/javascript/IJavaScript.h"
12 /* -------------------------- CBA_ActionHandler -------------------------- */
14 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi) :
16 m_pFormActionHandler(NULL),
17 m_pMediaActionHandler(NULL)
19 m_pFormActionHandler = new CPDFSDK_FormActionHandler;
22 CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler()
24 if(m_pFormActionHandler)
26 delete m_pFormActionHandler;
27 m_pFormActionHandler = NULL;
31 void CPDFSDK_ActionHandler::SetFormActionHandler(CPDFSDK_FormActionHandler* pHandler)
33 ASSERT(pHandler != NULL);
34 ASSERT(m_pFormActionHandler == NULL);
35 m_pFormActionHandler = pHandler;
38 void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler)
40 ASSERT(pHandler != NULL);
41 ASSERT(m_pMediaActionHandler == NULL);
42 m_pMediaActionHandler = pHandler;
45 void CPDFSDK_ActionHandler::Destroy()
51 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument
52 /*CReader_Document* pDocument, CReader_DocView *pDocView*/)
55 return ExecuteDocumentOpenAction(action, pDocument, /*pDocView, */list);
59 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName,
60 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
62 if (JsAction.GetType() == CPDF_Action::JavaScript)
64 CFX_WideString swJS = JsAction.GetJavaScript();
67 RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
75 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type,
76 CPDFSDK_Document* pDocument, CPDF_FormField* pFormField,
77 PDFSDK_FieldAction& data)
79 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
81 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript)
83 CFX_WideString swJS = JsAction.GetJavaScript();
86 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
93 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType,
94 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
97 return ExecuteDocumentPageAction(action, eType, pDocument,/* pDocView,*/ list);
100 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType,
101 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
104 return ExecuteDocumentPageAction(action, eType, pDocument,/* pDocView,*/ list);
107 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type,
108 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
111 return this->ExecuteBookMark(action, pDocument,/* pDocView,*/ pBookMark, list);
114 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type,
115 CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/ CPDFSDK_Annot* pScreen)
118 return this->ExecuteScreenAction(action, type, pDocument,/* pDocView,*/ pScreen, list);
121 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
122 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
125 return ExecuteLinkAction(action, pDocument,/* pDocView,*/ list);
128 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type,
129 CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/
130 CPDF_FormField* pFormField, PDFSDK_FieldAction& data)
133 return ExecuteFieldAction(action, type, pDocument,/* pDocView,*/ pFormField, data, list);
136 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,
137 /*CReader_DocView *pDocView,*/ CFX_PtrList& list)
139 ASSERT(pDocument != NULL);
141 if (list.Find((CPDF_Dictionary*)action))
143 list.AddTail((CPDF_Dictionary*)action);
145 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
147 if (action.GetType() == CPDF_Action::JavaScript)
149 if(pEnv->IsJSInitiated())
151 CFX_WideString swJS = action.GetJavaScript();
154 RunDocumentOpenJavaScript(pDocument, L"", swJS);
160 DoAction_NoJs(action, pDocument/*, pDocView*/);
163 // if (!IsValidDocView(pDocument, pDocView))
166 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
168 CPDF_Action subaction = action.GetSubAction(i);
169 if (!ExecuteDocumentOpenAction(subaction, pDocument,/* pDocView,*/ list)) return FALSE;
175 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,
176 /*CReader_DocView* pDocView,*/ CFX_PtrList& list)
178 ASSERT(pDocument != NULL);
180 if (list.Find((CPDF_Dictionary*)action))
182 list.AddTail((CPDF_Dictionary*)action);
184 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
186 if (action.GetType() == CPDF_Action::JavaScript)
188 if(pEnv->IsJSInitiated())
190 CFX_WideString swJS = action.GetJavaScript();
193 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //????
194 ASSERT(pRuntime != NULL);
196 pRuntime->SetReaderDocument(pDocument);
198 IFXJS_Context* pContext = pRuntime->NewContext();
199 ASSERT(pContext != NULL);
201 pContext->OnLink_MouseUp(pDocument);
203 CFX_WideString csInfo;
204 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
207 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
210 pRuntime->ReleaseContext(pContext);
216 DoAction_NoJs(action, pDocument/*, pDocView*/);
219 // if (!IsValidDocView(pDocument, pDocView))
222 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
224 CPDF_Action subaction = action.GetSubAction(i);
225 if (!ExecuteLinkAction(subaction, pDocument,/* pDocView,*/ list)) return FALSE;
231 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
232 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CFX_PtrList& list)
234 ASSERT(pDocument != NULL);
236 if (list.Find((CPDF_Dictionary*)action))
238 list.AddTail((CPDF_Dictionary*)action);
240 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
242 if (action.GetType() == CPDF_Action::JavaScript)
244 if(pEnv->IsJSInitiated())
246 CFX_WideString swJS = action.GetJavaScript();
249 RunDocumentPageJavaScript(pDocument, type, swJS);
255 DoAction_NoJs(action, pDocument/*, pDocView*/);
258 if (!IsValidDocView(pDocument/*, pDocView*/))
261 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
263 CPDF_Action subaction = action.GetSubAction(i);
264 if (!ExecuteDocumentPageAction(subaction, type, pDocument,/* pDocView,*/ list)) return FALSE;
270 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, CPDF_Dictionary* pFieldDict)
272 ASSERT(m_pEvi != NULL);
273 ASSERT(pDocument != NULL);
274 ASSERT(pFieldDict != NULL);
276 if (1/*m_pApp->IsValidDocument(pDocument)*/)
278 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
279 ASSERT(pInterForm != NULL);
281 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
282 ASSERT(pPDFInterForm != NULL);
284 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
290 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
291 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDF_FormField* pFormField,
292 PDFSDK_FieldAction& data, CFX_PtrList& list)
294 ASSERT(pDocument != NULL);
296 if (list.Find((CPDF_Dictionary*)action))
298 list.AddTail((CPDF_Dictionary*)action);
300 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
302 if (action.GetType() == CPDF_Action::JavaScript)
304 if(pEnv->IsJSInitiated())
306 CFX_WideString swJS = action.GetJavaScript();
309 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
310 if (!IsValidField(pDocument, pFormField->GetFieldDict()))
317 DoAction_NoJs(action, pDocument/*, pDocView*/);
318 // if (!IsValidDocView(pDocument, pDocView))
322 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
324 CPDF_Action subaction = action.GetSubAction(i);
325 if (!ExecuteFieldAction(subaction, type, pDocument,/* pDocView,*/ pFormField, data, list)) return FALSE;
331 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
332 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list)
334 ASSERT(pDocument != NULL);
336 if (list.Find((CPDF_Dictionary*)action))
338 list.AddTail((CPDF_Dictionary*)action);
340 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
342 if (action.GetType() == CPDF_Action::JavaScript)
344 if(pEnv->IsJSInitiated())
346 CFX_WideString swJS = action.GetJavaScript();
349 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
350 ASSERT(pRuntime != NULL);
352 pRuntime->SetReaderDocument(pDocument);
354 IFXJS_Context* pContext = pRuntime->NewContext();
355 ASSERT(pContext != NULL);
359 // case CPDF_AAction::CursorEnter:
360 // pContext->OnScreen_MouseEnter(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
362 // case CPDF_AAction::CursorExit:
363 // pContext->OnScreen_MouseExit(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
365 // case CPDF_AAction::ButtonDown:
366 // pContext->OnScreen_MouseDown(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
368 // case CPDF_AAction::ButtonUp:
369 // pContext->OnScreen_MouseUp(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
371 // case CPDF_AAction::GetFocus:
372 // pContext->OnScreen_Focus(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
374 // case CPDF_AAction::LoseFocus:
375 // pContext->OnScreen_Blur(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
377 // case CPDF_AAction::PageOpen:
378 // pContext->OnScreen_Open(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
380 // case CPDF_AAction::PageClose:
381 // pContext->OnScreen_Close(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
383 // case CPDF_AAction::PageVisible:
384 // pContext->OnScreen_InView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
386 // case CPDF_AAction::PageInvisible:
387 // pContext->OnScreen_OutView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
394 CFX_WideString csInfo;
395 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
398 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
401 pRuntime->ReleaseContext(pContext);
407 DoAction_NoJs(action, pDocument/*, pDocView*/);
410 // if (!IsValidDocView(pDocument, pDocView))
413 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
415 CPDF_Action subaction = action.GetSubAction(i);
416 if (!ExecuteScreenAction(subaction, type, pDocument,/* pDocView,*/ pScreen, list)) return FALSE;
422 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument,
423 /*CReader_DocView* pDocView,*/ CPDF_Bookmark* pBookmark, CFX_PtrList& list)
425 ASSERT(pDocument != NULL);
427 if (list.Find((CPDF_Dictionary*)action))
429 list.AddTail((CPDF_Dictionary*)action);
431 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
433 if (action.GetType() == CPDF_Action::JavaScript)
435 if(pEnv->IsJSInitiated())
437 CFX_WideString swJS = action.GetJavaScript();
440 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
441 ASSERT(pRuntime != NULL);
443 pRuntime->SetReaderDocument(pDocument);
445 IFXJS_Context* pContext = pRuntime->NewContext();
446 ASSERT(pContext != NULL);
448 pContext->OnBookmark_MouseUp(pBookmark);
450 CFX_WideString csInfo;
451 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
454 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
457 pRuntime->ReleaseContext(pContext);
463 DoAction_NoJs(action, pDocument/*, pDocView*/);
466 // if (!IsValidDocView(pDocument, pDocView))
469 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
471 CPDF_Action subaction = action.GetSubAction(i);
472 if (!ExecuteBookMark(subaction, pDocument,/* pDocView,*/ pBookmark, list)) return FALSE;
478 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
480 ASSERT(pDocument != NULL);
482 switch (action.GetType())
484 case CPDF_Action::GoTo:
485 DoAction_GoTo(pDocument,/* pDocView,*/ action);
487 case CPDF_Action::GoToR:
488 DoAction_GoToR(pDocument, action);
490 case CPDF_Action::GoToE:
492 case CPDF_Action::Launch:
493 DoAction_Launch(pDocument, action);
495 case CPDF_Action::Thread:
497 case CPDF_Action::URI:
498 DoAction_URI(pDocument, action);
500 case CPDF_Action::Sound:
501 if (m_pMediaActionHandler)
503 m_pMediaActionHandler->DoAction_Sound(action, pDocument/*, pDocView*/);
506 case CPDF_Action::Movie:
507 if (m_pMediaActionHandler)
509 m_pMediaActionHandler->DoAction_Movie(action, pDocument/*, pDocView*/);
512 case CPDF_Action::Hide:
513 if (m_pFormActionHandler)
515 m_pFormActionHandler->DoAction_Hide(action, pDocument);
518 case CPDF_Action::Named:
519 DoAction_Named(pDocument, action);
521 case CPDF_Action::SubmitForm:
522 if (m_pFormActionHandler)
524 m_pFormActionHandler->DoAction_SubmitForm(action, pDocument/*, pDocView*/);
527 case CPDF_Action::ResetForm:
528 if (m_pFormActionHandler)
530 m_pFormActionHandler->DoAction_ResetForm(action, pDocument);
533 case CPDF_Action::ImportData:
534 if (m_pFormActionHandler)
536 m_pFormActionHandler->DoAction_ImportData(action, pDocument/*, pDocView*/);
539 case CPDF_Action::JavaScript:
542 case CPDF_Action::SetOCGState:
543 DoAction_SetOCGState(pDocument, /*pDocView,*/ action);
545 case CPDF_Action::Rendition:
546 if (m_pMediaActionHandler)
548 m_pMediaActionHandler->DoAction_Rendition(action, pDocument/*, pDocView*/);
551 case CPDF_Action::Trans:
553 case CPDF_Action::GoTo3DView:
560 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
562 ASSERT(pDocument != NULL);
563 //ASSERT(pDocView != NULL);
565 //return pDocument->IsValidDocView(pDocView);
569 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/
570 const CPDF_Action& action)
572 ASSERT(pDocument != NULL);
573 // ASSERT(pDocView != NULL);
574 ASSERT(action != NULL);
576 CPDF_Document* pPDFDocument = pDocument->GetDocument();
577 ASSERT(pPDFDocument != NULL);
578 CPDFDoc_Environment* pApp = pDocument->GetEnv();
579 ASSERT(pApp != NULL);
581 CPDF_Dest MyDest = action.GetDest(pPDFDocument);
582 int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
583 int nFitType = MyDest.GetZoomMode();
584 const CPDF_Array * pMyArray = (CPDF_Array*)MyDest.m_pObj;
585 float* pPosAry = NULL;
587 if (pMyArray != NULL)
589 pPosAry = new float[pMyArray->GetCount()];
591 for (int i = 2; i < (int)pMyArray->GetCount(); i++)
593 pPosAry[j++] = pMyArray->GetFloat(i);
597 pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
602 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action)
607 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action)
612 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action)
614 ASSERT(pDocument != NULL);
615 ASSERT(action != NULL);
617 CPDFDoc_Environment* pApp = pDocument->GetEnv();
618 ASSERT(pApp != NULL);
620 CFX_ByteString sURI = action.GetURI(pDocument->GetDocument());
621 pApp->FFI_DoURIAction(FX_LPCSTR(sURI));
624 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action)
626 ASSERT(pDocument != NULL);
627 ASSERT(action != NULL);
629 CFX_ByteString csName = action.GetNamedAction();
630 pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
634 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ const CPDF_Action& action)
638 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type,
639 PDFSDK_FieldAction& data, const CFX_WideString& script)
641 ASSERT(type != CPDF_AAction::Calculate);
642 ASSERT(type != CPDF_AAction::Format);
644 ASSERT(pDocument != NULL);
646 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
647 ASSERT(pRuntime != NULL);
649 pRuntime->SetReaderDocument(pDocument);
651 IFXJS_Context* pContext = pRuntime->NewContext();
652 ASSERT(pContext != NULL);
656 case CPDF_AAction::CursorEnter:
657 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField);
659 case CPDF_AAction::CursorExit:
660 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField);
662 case CPDF_AAction::ButtonDown:
663 pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField);
665 case CPDF_AAction::ButtonUp:
666 pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField);
668 case CPDF_AAction::GetFocus:
669 pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, data.sValue);
671 case CPDF_AAction::LoseFocus:
672 pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, data.sValue);
674 case CPDF_AAction::KeyStroke:
675 pContext->OnField_Keystroke(data.nCommitKey, data.sChange, data.sChangeEx, data.bKeyDown,
676 data.bModifier, data.nSelEnd, data.nSelStart, data.bShift, pFormField, data.sValue,
677 data.bWillCommit, data.bFieldFull, data.bRC);
679 case CPDF_AAction::Validate:
680 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, data.bModifier,
681 data.bShift, pFormField, data.sValue, data.bRC);
688 CFX_WideString csInfo;
689 FX_BOOL bRet = pContext->RunScript(script, csInfo);
692 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
695 pRuntime->ReleaseContext(pContext);
698 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script)
700 ASSERT(pDocument != NULL);
702 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
703 ASSERT(pRuntime != NULL);
705 pRuntime->SetReaderDocument(pDocument);
707 IFXJS_Context* pContext = pRuntime->NewContext();
708 ASSERT(pContext != NULL);
710 pContext->OnDoc_Open(pDocument, sScriptName);
712 CFX_WideString csInfo;
713 FX_BOOL bRet = pContext->RunScript(script, csInfo);
716 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
719 pRuntime->ReleaseContext(pContext);
722 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script)
724 ASSERT(pDocument != NULL);
726 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
727 ASSERT(pRuntime != NULL);
729 pRuntime->SetReaderDocument(pDocument);
731 IFXJS_Context* pContext = pRuntime->NewContext();
732 ASSERT(pContext != NULL);
736 case CPDF_AAction::OpenPage:
737 pContext->OnPage_Open(pDocument);
739 case CPDF_AAction::ClosePage:
740 pContext->OnPage_Close(pDocument);
742 case CPDF_AAction::CloseDocument:
743 pContext->OnDoc_WillClose(pDocument);
745 case CPDF_AAction::SaveDocument:
746 pContext->OnDoc_WillSave(pDocument);
748 case CPDF_AAction::DocumentSaved:
749 pContext->OnDoc_DidSave(pDocument);
751 case CPDF_AAction::PrintDocument:
752 pContext->OnDoc_WillPrint(pDocument);
754 case CPDF_AAction::DocumentPrinted:
755 pContext->OnDoc_DidPrint(pDocument);
757 case CPDF_AAction::PageVisible:
758 pContext->OnPage_InView(pDocument);
760 case CPDF_AAction::PageInvisible:
761 pContext->OnPage_OutView(pDocument);
768 CFX_WideString csInfo;
769 FX_BOOL bRet = pContext->RunScript(script, csInfo);
772 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
775 pRuntime->ReleaseContext(pContext);
779 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument)
781 ASSERT(pDocument != NULL);
783 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
784 ASSERT(pInterForm != NULL);
786 if (pInterForm->DoAction_Hide(action))
788 pDocument->SetChangeMark();
795 FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
797 ASSERT(pDocument != NULL);
799 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
800 ASSERT(pInterForm != NULL);
802 return pInterForm->DoAction_SubmitForm(action);
805 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
807 ASSERT(pDocument != NULL);
809 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
810 ASSERT(pInterForm != NULL);
812 if (pInterForm->DoAction_ResetForm(action))
820 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData(const CPDF_Action& action, CPDFSDK_Document* pDocument)
822 ASSERT(pDocument != NULL);
824 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
825 ASSERT(pInterForm != NULL);
827 if (pInterForm->DoAction_ImportData(action))
829 pDocument->SetChangeMark();
836 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Rendition(const CPDF_Action& action, CPDFSDK_Document* pDocument)
841 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Sound(const CPDF_Action& action, CPDFSDK_Document* pDocument)
846 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument)