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) :
15 m_pFormActionHandler(NULL),
16 m_pMediaActionHandler(NULL)
18 m_pFormActionHandler = new CPDFSDK_FormActionHandler;
21 CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler()
23 if(m_pFormActionHandler)
25 delete m_pFormActionHandler;
26 m_pFormActionHandler = NULL;
30 void CPDFSDK_ActionHandler::SetFormActionHandler(CPDFSDK_FormActionHandler* pHandler)
32 ASSERT(pHandler != NULL);
33 ASSERT(m_pFormActionHandler == NULL);
34 m_pFormActionHandler = pHandler;
37 void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler)
39 ASSERT(pHandler != NULL);
40 ASSERT(m_pMediaActionHandler == NULL);
41 m_pMediaActionHandler = pHandler;
44 void CPDFSDK_ActionHandler::Destroy()
50 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument
51 /*CReader_Document* pDocument, CReader_DocView *pDocView*/)
54 return ExecuteDocumentOpenAction(action, pDocument, /*pDocView, */list);
58 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName,
59 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
61 if (JsAction.GetType() == CPDF_Action::JavaScript)
63 CFX_WideString swJS = JsAction.GetJavaScript();
66 RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
74 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type,
75 CPDFSDK_Document* pDocument, CPDF_FormField* pFormField,
76 PDFSDK_FieldAction& data)
78 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
80 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript)
82 CFX_WideString swJS = JsAction.GetJavaScript();
85 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
92 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType,
93 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
96 return ExecuteDocumentPageAction(action, eType, pDocument,/* pDocView,*/ list);
99 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType,
100 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
103 return ExecuteDocumentPageAction(action, eType, pDocument,/* pDocView,*/ list);
106 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type,
107 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
110 return this->ExecuteBookMark(action, pDocument,/* pDocView,*/ pBookMark, list);
113 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type,
114 CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/ CPDFSDK_Annot* pScreen)
117 return this->ExecuteScreenAction(action, type, pDocument,/* pDocView,*/ pScreen, list);
120 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
121 CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/)
124 return ExecuteLinkAction(action, pDocument,/* pDocView,*/ list);
127 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type,
128 CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/
129 CPDF_FormField* pFormField, PDFSDK_FieldAction& data)
132 return ExecuteFieldAction(action, type, pDocument,/* pDocView,*/ pFormField, data, list);
135 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,
136 /*CReader_DocView *pDocView,*/ CFX_PtrList& list)
138 ASSERT(pDocument != NULL);
140 if (list.Find((CPDF_Dictionary*)action))
142 list.AddTail((CPDF_Dictionary*)action);
144 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
146 if (action.GetType() == CPDF_Action::JavaScript)
148 if(pEnv->IsJSInitiated())
150 CFX_WideString swJS = action.GetJavaScript();
153 RunDocumentOpenJavaScript(pDocument, L"", swJS);
159 DoAction_NoJs(action, pDocument/*, pDocView*/);
162 // if (!IsValidDocView(pDocument, pDocView))
165 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
167 CPDF_Action subaction = action.GetSubAction(i);
168 if (!ExecuteDocumentOpenAction(subaction, pDocument,/* pDocView,*/ list)) return FALSE;
174 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,
175 /*CReader_DocView* pDocView,*/ CFX_PtrList& list)
177 ASSERT(pDocument != NULL);
179 if (list.Find((CPDF_Dictionary*)action))
181 list.AddTail((CPDF_Dictionary*)action);
183 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
185 if (action.GetType() == CPDF_Action::JavaScript)
187 if(pEnv->IsJSInitiated())
189 CFX_WideString swJS = action.GetJavaScript();
192 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //????
193 ASSERT(pRuntime != NULL);
195 pRuntime->SetReaderDocument(pDocument);
197 IFXJS_Context* pContext = pRuntime->NewContext();
198 ASSERT(pContext != NULL);
200 pContext->OnLink_MouseUp(pDocument);
202 CFX_WideString csInfo;
203 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
206 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
209 pRuntime->ReleaseContext(pContext);
215 DoAction_NoJs(action, pDocument/*, pDocView*/);
218 // if (!IsValidDocView(pDocument, pDocView))
221 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
223 CPDF_Action subaction = action.GetSubAction(i);
224 if (!ExecuteLinkAction(subaction, pDocument,/* pDocView,*/ list)) return FALSE;
230 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
231 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CFX_PtrList& list)
233 ASSERT(pDocument != NULL);
235 if (list.Find((CPDF_Dictionary*)action))
237 list.AddTail((CPDF_Dictionary*)action);
239 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
241 if (action.GetType() == CPDF_Action::JavaScript)
243 if(pEnv->IsJSInitiated())
245 CFX_WideString swJS = action.GetJavaScript();
248 RunDocumentPageJavaScript(pDocument, type, swJS);
254 DoAction_NoJs(action, pDocument/*, pDocView*/);
257 if (!IsValidDocView(pDocument/*, pDocView*/))
260 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
262 CPDF_Action subaction = action.GetSubAction(i);
263 if (!ExecuteDocumentPageAction(subaction, type, pDocument,/* pDocView,*/ list)) return FALSE;
269 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, CPDF_Dictionary* pFieldDict)
271 ASSERT(pDocument != NULL);
272 ASSERT(pFieldDict != NULL);
274 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
275 ASSERT(pInterForm != NULL);
277 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
278 ASSERT(pPDFInterForm != NULL);
280 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
283 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
284 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDF_FormField* pFormField,
285 PDFSDK_FieldAction& data, CFX_PtrList& list)
287 ASSERT(pDocument != NULL);
289 if (list.Find((CPDF_Dictionary*)action))
291 list.AddTail((CPDF_Dictionary*)action);
293 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
295 if (action.GetType() == CPDF_Action::JavaScript)
297 if(pEnv->IsJSInitiated())
299 CFX_WideString swJS = action.GetJavaScript();
302 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
303 if (!IsValidField(pDocument, pFormField->GetFieldDict()))
310 DoAction_NoJs(action, pDocument/*, pDocView*/);
311 // if (!IsValidDocView(pDocument, pDocView))
315 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
317 CPDF_Action subaction = action.GetSubAction(i);
318 if (!ExecuteFieldAction(subaction, type, pDocument,/* pDocView,*/ pFormField, data, list)) return FALSE;
324 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
325 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list)
327 ASSERT(pDocument != NULL);
329 if (list.Find((CPDF_Dictionary*)action))
331 list.AddTail((CPDF_Dictionary*)action);
333 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
335 if (action.GetType() == CPDF_Action::JavaScript)
337 if(pEnv->IsJSInitiated())
339 CFX_WideString swJS = action.GetJavaScript();
342 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
343 ASSERT(pRuntime != NULL);
345 pRuntime->SetReaderDocument(pDocument);
347 IFXJS_Context* pContext = pRuntime->NewContext();
348 ASSERT(pContext != NULL);
352 // case CPDF_AAction::CursorEnter:
353 // pContext->OnScreen_MouseEnter(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
355 // case CPDF_AAction::CursorExit:
356 // pContext->OnScreen_MouseExit(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
358 // case CPDF_AAction::ButtonDown:
359 // pContext->OnScreen_MouseDown(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
361 // case CPDF_AAction::ButtonUp:
362 // pContext->OnScreen_MouseUp(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
364 // case CPDF_AAction::GetFocus:
365 // pContext->OnScreen_Focus(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
367 // case CPDF_AAction::LoseFocus:
368 // pContext->OnScreen_Blur(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
370 // case CPDF_AAction::PageOpen:
371 // pContext->OnScreen_Open(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
373 // case CPDF_AAction::PageClose:
374 // pContext->OnScreen_Close(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
376 // case CPDF_AAction::PageVisible:
377 // pContext->OnScreen_InView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
379 // case CPDF_AAction::PageInvisible:
380 // pContext->OnScreen_OutView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
387 CFX_WideString csInfo;
388 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
391 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
394 pRuntime->ReleaseContext(pContext);
400 DoAction_NoJs(action, pDocument/*, pDocView*/);
403 // if (!IsValidDocView(pDocument, pDocView))
406 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
408 CPDF_Action subaction = action.GetSubAction(i);
409 if (!ExecuteScreenAction(subaction, type, pDocument,/* pDocView,*/ pScreen, list)) return FALSE;
415 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument,
416 /*CReader_DocView* pDocView,*/ CPDF_Bookmark* pBookmark, CFX_PtrList& list)
418 ASSERT(pDocument != NULL);
420 if (list.Find((CPDF_Dictionary*)action))
422 list.AddTail((CPDF_Dictionary*)action);
424 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
426 if (action.GetType() == CPDF_Action::JavaScript)
428 if(pEnv->IsJSInitiated())
430 CFX_WideString swJS = action.GetJavaScript();
433 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
434 ASSERT(pRuntime != NULL);
436 pRuntime->SetReaderDocument(pDocument);
438 IFXJS_Context* pContext = pRuntime->NewContext();
439 ASSERT(pContext != NULL);
441 pContext->OnBookmark_MouseUp(pBookmark);
443 CFX_WideString csInfo;
444 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
447 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
450 pRuntime->ReleaseContext(pContext);
456 DoAction_NoJs(action, pDocument/*, pDocView*/);
459 // if (!IsValidDocView(pDocument, pDocView))
462 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
464 CPDF_Action subaction = action.GetSubAction(i);
465 if (!ExecuteBookMark(subaction, pDocument,/* pDocView,*/ pBookmark, list)) return FALSE;
471 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
473 ASSERT(pDocument != NULL);
475 switch (action.GetType())
477 case CPDF_Action::GoTo:
478 DoAction_GoTo(pDocument,/* pDocView,*/ action);
480 case CPDF_Action::GoToR:
481 DoAction_GoToR(pDocument, action);
483 case CPDF_Action::GoToE:
485 case CPDF_Action::Launch:
486 DoAction_Launch(pDocument, action);
488 case CPDF_Action::Thread:
490 case CPDF_Action::URI:
491 DoAction_URI(pDocument, action);
493 case CPDF_Action::Sound:
494 if (m_pMediaActionHandler)
496 m_pMediaActionHandler->DoAction_Sound(action, pDocument/*, pDocView*/);
499 case CPDF_Action::Movie:
500 if (m_pMediaActionHandler)
502 m_pMediaActionHandler->DoAction_Movie(action, pDocument/*, pDocView*/);
505 case CPDF_Action::Hide:
506 if (m_pFormActionHandler)
508 m_pFormActionHandler->DoAction_Hide(action, pDocument);
511 case CPDF_Action::Named:
512 DoAction_Named(pDocument, action);
514 case CPDF_Action::SubmitForm:
515 if (m_pFormActionHandler)
517 m_pFormActionHandler->DoAction_SubmitForm(action, pDocument/*, pDocView*/);
520 case CPDF_Action::ResetForm:
521 if (m_pFormActionHandler)
523 m_pFormActionHandler->DoAction_ResetForm(action, pDocument);
526 case CPDF_Action::ImportData:
527 if (m_pFormActionHandler)
529 m_pFormActionHandler->DoAction_ImportData(action, pDocument/*, pDocView*/);
532 case CPDF_Action::JavaScript:
535 case CPDF_Action::SetOCGState:
536 DoAction_SetOCGState(pDocument, /*pDocView,*/ action);
538 case CPDF_Action::Rendition:
539 if (m_pMediaActionHandler)
541 m_pMediaActionHandler->DoAction_Rendition(action, pDocument/*, pDocView*/);
544 case CPDF_Action::Trans:
546 case CPDF_Action::GoTo3DView:
553 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
555 ASSERT(pDocument != NULL);
556 //ASSERT(pDocView != NULL);
558 //return pDocument->IsValidDocView(pDocView);
562 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/
563 const CPDF_Action& action)
565 ASSERT(pDocument != NULL);
566 // ASSERT(pDocView != NULL);
567 ASSERT(action != NULL);
569 CPDF_Document* pPDFDocument = pDocument->GetDocument();
570 ASSERT(pPDFDocument != NULL);
571 CPDFDoc_Environment* pApp = pDocument->GetEnv();
572 ASSERT(pApp != NULL);
574 CPDF_Dest MyDest = action.GetDest(pPDFDocument);
575 int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
576 int nFitType = MyDest.GetZoomMode();
577 const CPDF_Array * pMyArray = (CPDF_Array*)MyDest.m_pObj;
578 float* pPosAry = NULL;
580 if (pMyArray != NULL)
582 pPosAry = new float[pMyArray->GetCount()];
584 for (int i = 2; i < (int)pMyArray->GetCount(); i++)
586 pPosAry[j++] = pMyArray->GetFloat(i);
590 pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
595 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action)
600 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action)
605 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action)
607 ASSERT(pDocument != NULL);
608 ASSERT(action != NULL);
610 CPDFDoc_Environment* pApp = pDocument->GetEnv();
611 ASSERT(pApp != NULL);
613 CFX_ByteString sURI = action.GetURI(pDocument->GetDocument());
614 pApp->FFI_DoURIAction(FX_LPCSTR(sURI));
617 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action)
619 ASSERT(pDocument != NULL);
620 ASSERT(action != NULL);
622 CFX_ByteString csName = action.GetNamedAction();
623 pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
627 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ const CPDF_Action& action)
631 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type,
632 PDFSDK_FieldAction& data, const CFX_WideString& script)
634 ASSERT(type != CPDF_AAction::Calculate);
635 ASSERT(type != CPDF_AAction::Format);
637 ASSERT(pDocument != NULL);
639 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
640 ASSERT(pRuntime != NULL);
642 pRuntime->SetReaderDocument(pDocument);
644 IFXJS_Context* pContext = pRuntime->NewContext();
645 ASSERT(pContext != NULL);
649 case CPDF_AAction::CursorEnter:
650 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField);
652 case CPDF_AAction::CursorExit:
653 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField);
655 case CPDF_AAction::ButtonDown:
656 pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField);
658 case CPDF_AAction::ButtonUp:
659 pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField);
661 case CPDF_AAction::GetFocus:
662 pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, data.sValue);
664 case CPDF_AAction::LoseFocus:
665 pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, data.sValue);
667 case CPDF_AAction::KeyStroke:
668 pContext->OnField_Keystroke(data.nCommitKey, data.sChange, data.sChangeEx, data.bKeyDown,
669 data.bModifier, data.nSelEnd, data.nSelStart, data.bShift, pFormField, data.sValue,
670 data.bWillCommit, data.bFieldFull, data.bRC);
672 case CPDF_AAction::Validate:
673 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, data.bModifier,
674 data.bShift, pFormField, data.sValue, data.bRC);
681 CFX_WideString csInfo;
682 FX_BOOL bRet = pContext->RunScript(script, csInfo);
685 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
688 pRuntime->ReleaseContext(pContext);
691 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script)
693 ASSERT(pDocument != NULL);
695 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
696 ASSERT(pRuntime != NULL);
698 pRuntime->SetReaderDocument(pDocument);
700 IFXJS_Context* pContext = pRuntime->NewContext();
701 ASSERT(pContext != NULL);
703 pContext->OnDoc_Open(pDocument, sScriptName);
705 CFX_WideString csInfo;
706 FX_BOOL bRet = pContext->RunScript(script, csInfo);
709 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
712 pRuntime->ReleaseContext(pContext);
715 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script)
717 ASSERT(pDocument != NULL);
719 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
720 ASSERT(pRuntime != NULL);
722 pRuntime->SetReaderDocument(pDocument);
724 IFXJS_Context* pContext = pRuntime->NewContext();
725 ASSERT(pContext != NULL);
729 case CPDF_AAction::OpenPage:
730 pContext->OnPage_Open(pDocument);
732 case CPDF_AAction::ClosePage:
733 pContext->OnPage_Close(pDocument);
735 case CPDF_AAction::CloseDocument:
736 pContext->OnDoc_WillClose(pDocument);
738 case CPDF_AAction::SaveDocument:
739 pContext->OnDoc_WillSave(pDocument);
741 case CPDF_AAction::DocumentSaved:
742 pContext->OnDoc_DidSave(pDocument);
744 case CPDF_AAction::PrintDocument:
745 pContext->OnDoc_WillPrint(pDocument);
747 case CPDF_AAction::DocumentPrinted:
748 pContext->OnDoc_DidPrint(pDocument);
750 case CPDF_AAction::PageVisible:
751 pContext->OnPage_InView(pDocument);
753 case CPDF_AAction::PageInvisible:
754 pContext->OnPage_OutView(pDocument);
761 CFX_WideString csInfo;
762 FX_BOOL bRet = pContext->RunScript(script, csInfo);
765 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
768 pRuntime->ReleaseContext(pContext);
772 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument)
774 ASSERT(pDocument != NULL);
776 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
777 ASSERT(pInterForm != NULL);
779 if (pInterForm->DoAction_Hide(action))
781 pDocument->SetChangeMark();
788 FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
790 ASSERT(pDocument != NULL);
792 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
793 ASSERT(pInterForm != NULL);
795 return pInterForm->DoAction_SubmitForm(action);
798 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
800 ASSERT(pDocument != NULL);
802 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
803 ASSERT(pInterForm != NULL);
805 if (pInterForm->DoAction_ResetForm(action))
813 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData(const CPDF_Action& action, CPDFSDK_Document* pDocument)
815 ASSERT(pDocument != NULL);
817 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
818 ASSERT(pInterForm != NULL);
820 if (pInterForm->DoAction_ImportData(action))
822 pDocument->SetChangeMark();
829 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Rendition(const CPDF_Action& action, CPDFSDK_Document* pDocument)
834 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Sound(const CPDF_Action& action, CPDFSDK_Document* pDocument)
839 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument)