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/fpdfxfa/fpdfxfa_doc.h"
9 #include "../include/fsdk_mgr.h"
10 #include "../include/fsdk_actionhandler.h"
11 #include "../include/javascript/IJavaScript.h"
13 /* -------------------------- CBA_ActionHandler -------------------------- */
15 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(pDocument != NULL);
273 ASSERT(pFieldDict != NULL);
275 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
276 ASSERT(pInterForm != NULL);
278 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
279 ASSERT(pPDFInterForm != NULL);
281 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
284 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
285 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDF_FormField* pFormField,
286 PDFSDK_FieldAction& data, CFX_PtrList& list)
288 ASSERT(pDocument != NULL);
290 if (list.Find((CPDF_Dictionary*)action))
292 list.AddTail((CPDF_Dictionary*)action);
294 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
296 if (action.GetType() == CPDF_Action::JavaScript)
298 if(pEnv->IsJSInitiated())
300 CFX_WideString swJS = action.GetJavaScript();
303 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
304 if (!IsValidField(pDocument, pFormField->GetFieldDict()))
311 DoAction_NoJs(action, pDocument/*, pDocView*/);
312 // if (!IsValidDocView(pDocument, pDocView))
316 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
318 CPDF_Action subaction = action.GetSubAction(i);
319 if (!ExecuteFieldAction(subaction, type, pDocument,/* pDocView,*/ pFormField, data, list)) return FALSE;
325 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type,
326 CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list)
328 ASSERT(pDocument != NULL);
330 if (list.Find((CPDF_Dictionary*)action))
332 list.AddTail((CPDF_Dictionary*)action);
334 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
336 if (action.GetType() == CPDF_Action::JavaScript)
338 if(pEnv->IsJSInitiated())
340 CFX_WideString swJS = action.GetJavaScript();
343 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
344 ASSERT(pRuntime != NULL);
346 pRuntime->SetReaderDocument(pDocument);
348 IFXJS_Context* pContext = pRuntime->NewContext();
349 ASSERT(pContext != NULL);
353 // case CPDF_AAction::CursorEnter:
354 // pContext->OnScreen_MouseEnter(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
356 // case CPDF_AAction::CursorExit:
357 // pContext->OnScreen_MouseExit(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
359 // case CPDF_AAction::ButtonDown:
360 // pContext->OnScreen_MouseDown(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
362 // case CPDF_AAction::ButtonUp:
363 // pContext->OnScreen_MouseUp(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
365 // case CPDF_AAction::GetFocus:
366 // pContext->OnScreen_Focus(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
368 // case CPDF_AAction::LoseFocus:
369 // pContext->OnScreen_Blur(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
371 // case CPDF_AAction::PageOpen:
372 // pContext->OnScreen_Open(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
374 // case CPDF_AAction::PageClose:
375 // pContext->OnScreen_Close(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
377 // case CPDF_AAction::PageVisible:
378 // pContext->OnScreen_InView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
380 // case CPDF_AAction::PageInvisible:
381 // pContext->OnScreen_OutView(IsCTRLpressed(), IsSHIFTpressed(), pScreen);
388 CFX_WideString csInfo;
389 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
392 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
395 pRuntime->ReleaseContext(pContext);
401 DoAction_NoJs(action, pDocument/*, pDocView*/);
404 // if (!IsValidDocView(pDocument, pDocView))
407 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
409 CPDF_Action subaction = action.GetSubAction(i);
410 if (!ExecuteScreenAction(subaction, type, pDocument,/* pDocView,*/ pScreen, list)) return FALSE;
416 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument,
417 /*CReader_DocView* pDocView,*/ CPDF_Bookmark* pBookmark, CFX_PtrList& list)
419 ASSERT(pDocument != NULL);
421 if (list.Find((CPDF_Dictionary*)action))
423 list.AddTail((CPDF_Dictionary*)action);
425 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
427 if (action.GetType() == CPDF_Action::JavaScript)
429 if(pEnv->IsJSInitiated())
431 CFX_WideString swJS = action.GetJavaScript();
434 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
435 ASSERT(pRuntime != NULL);
437 pRuntime->SetReaderDocument(pDocument);
439 IFXJS_Context* pContext = pRuntime->NewContext();
440 ASSERT(pContext != NULL);
442 pContext->OnBookmark_MouseUp(pBookmark);
444 CFX_WideString csInfo;
445 FX_BOOL bRet = pContext->RunScript(swJS, csInfo);
448 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
451 pRuntime->ReleaseContext(pContext);
457 DoAction_NoJs(action, pDocument/*, pDocView*/);
460 // if (!IsValidDocView(pDocument, pDocView))
463 for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
465 CPDF_Action subaction = action.GetSubAction(i);
466 if (!ExecuteBookMark(subaction, pDocument,/* pDocView,*/ pBookmark, list)) return FALSE;
472 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
474 ASSERT(pDocument != NULL);
476 switch (action.GetType())
478 case CPDF_Action::GoTo:
479 DoAction_GoTo(pDocument,/* pDocView,*/ action);
481 case CPDF_Action::GoToR:
482 DoAction_GoToR(pDocument, action);
484 case CPDF_Action::GoToE:
486 case CPDF_Action::Launch:
487 DoAction_Launch(pDocument, action);
489 case CPDF_Action::Thread:
491 case CPDF_Action::URI:
492 DoAction_URI(pDocument, action);
494 case CPDF_Action::Sound:
495 if (m_pMediaActionHandler)
497 m_pMediaActionHandler->DoAction_Sound(action, pDocument/*, pDocView*/);
500 case CPDF_Action::Movie:
501 if (m_pMediaActionHandler)
503 m_pMediaActionHandler->DoAction_Movie(action, pDocument/*, pDocView*/);
506 case CPDF_Action::Hide:
507 if (m_pFormActionHandler)
509 m_pFormActionHandler->DoAction_Hide(action, pDocument);
512 case CPDF_Action::Named:
513 DoAction_Named(pDocument, action);
515 case CPDF_Action::SubmitForm:
516 if (m_pFormActionHandler)
518 m_pFormActionHandler->DoAction_SubmitForm(action, pDocument/*, pDocView*/);
521 case CPDF_Action::ResetForm:
522 if (m_pFormActionHandler)
524 m_pFormActionHandler->DoAction_ResetForm(action, pDocument);
527 case CPDF_Action::ImportData:
528 if (m_pFormActionHandler)
530 m_pFormActionHandler->DoAction_ImportData(action, pDocument/*, pDocView*/);
533 case CPDF_Action::JavaScript:
536 case CPDF_Action::SetOCGState:
537 DoAction_SetOCGState(pDocument, /*pDocView,*/ action);
539 case CPDF_Action::Rendition:
540 if (m_pMediaActionHandler)
542 m_pMediaActionHandler->DoAction_Rendition(action, pDocument/*, pDocView*/);
545 case CPDF_Action::Trans:
547 case CPDF_Action::GoTo3DView:
554 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/)
556 ASSERT(pDocument != NULL);
557 //ASSERT(pDocView != NULL);
559 //return pDocument->IsValidDocView(pDocView);
563 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/
564 const CPDF_Action& action)
566 ASSERT(pDocument != NULL);
567 // ASSERT(pDocView != NULL);
568 ASSERT(action != NULL);
570 CPDF_Document* pPDFDocument = pDocument->GetDocument()->GetPDFDoc();
571 ASSERT(pPDFDocument != NULL);
572 CPDFDoc_Environment* pApp = pDocument->GetEnv();
573 ASSERT(pApp != NULL);
575 CPDF_Dest MyDest = action.GetDest(pPDFDocument);
576 int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
577 int nFitType = MyDest.GetZoomMode();
578 const CPDF_Array * pMyArray = (CPDF_Array*)MyDest.m_pObj;
579 float* pPosAry = NULL;
581 if (pMyArray != NULL)
583 pPosAry = new float[pMyArray->GetCount()];
585 for (int i = 2; i < (int)pMyArray->GetCount(); i++)
587 pPosAry[j++] = pMyArray->GetFloat(i);
591 pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
596 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action)
601 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action)
606 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action)
608 ASSERT(pDocument != NULL);
609 ASSERT(action != NULL);
611 CPDFDoc_Environment* pApp = pDocument->GetEnv();
612 ASSERT(pApp != NULL);
614 CFX_ByteString sURI = action.GetURI(pDocument->GetDocument()->GetPDFDoc());
615 pApp->FFI_DoURIAction(FX_LPCSTR(sURI));
618 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action)
620 ASSERT(pDocument != NULL);
621 ASSERT(action != NULL);
623 CFX_ByteString csName = action.GetNamedAction();
624 pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
628 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ const CPDF_Action& action)
632 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type,
633 PDFSDK_FieldAction& data, const CFX_WideString& script)
635 ASSERT(type != CPDF_AAction::Calculate);
636 ASSERT(type != CPDF_AAction::Format);
638 ASSERT(pDocument != NULL);
640 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
641 ASSERT(pRuntime != NULL);
643 pRuntime->SetReaderDocument(pDocument);
645 IFXJS_Context* pContext = pRuntime->NewContext();
646 ASSERT(pContext != NULL);
650 case CPDF_AAction::CursorEnter:
651 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField);
653 case CPDF_AAction::CursorExit:
654 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField);
656 case CPDF_AAction::ButtonDown:
657 pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField);
659 case CPDF_AAction::ButtonUp:
660 pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField);
662 case CPDF_AAction::GetFocus:
663 pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, data.sValue);
665 case CPDF_AAction::LoseFocus:
666 pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, data.sValue);
668 case CPDF_AAction::KeyStroke:
669 pContext->OnField_Keystroke(data.nCommitKey, data.sChange, data.sChangeEx, data.bKeyDown,
670 data.bModifier, data.nSelEnd, data.nSelStart, data.bShift, pFormField, data.sValue,
671 data.bWillCommit, data.bFieldFull, data.bRC);
673 case CPDF_AAction::Validate:
674 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, data.bModifier,
675 data.bShift, pFormField, data.sValue, data.bRC);
682 CFX_WideString csInfo;
683 FX_BOOL bRet = pContext->RunScript(script, csInfo);
686 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
689 pRuntime->ReleaseContext(pContext);
692 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script)
694 ASSERT(pDocument != NULL);
696 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
697 ASSERT(pRuntime != NULL);
699 pRuntime->SetReaderDocument(pDocument);
701 IFXJS_Context* pContext = pRuntime->NewContext();
702 ASSERT(pContext != NULL);
704 pContext->OnDoc_Open(pDocument, sScriptName);
706 CFX_WideString csInfo;
707 FX_BOOL bRet = pContext->RunScript(script, csInfo);
710 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
713 pRuntime->ReleaseContext(pContext);
716 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script)
718 ASSERT(pDocument != NULL);
720 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
721 ASSERT(pRuntime != NULL);
723 pRuntime->SetReaderDocument(pDocument);
725 IFXJS_Context* pContext = pRuntime->NewContext();
726 ASSERT(pContext != NULL);
730 case CPDF_AAction::OpenPage:
731 pContext->OnPage_Open(pDocument);
733 case CPDF_AAction::ClosePage:
734 pContext->OnPage_Close(pDocument);
736 case CPDF_AAction::CloseDocument:
737 pContext->OnDoc_WillClose(pDocument);
739 case CPDF_AAction::SaveDocument:
740 pContext->OnDoc_WillSave(pDocument);
742 case CPDF_AAction::DocumentSaved:
743 pContext->OnDoc_DidSave(pDocument);
745 case CPDF_AAction::PrintDocument:
746 pContext->OnDoc_WillPrint(pDocument);
748 case CPDF_AAction::DocumentPrinted:
749 pContext->OnDoc_DidPrint(pDocument);
751 case CPDF_AAction::PageVisible:
752 pContext->OnPage_InView(pDocument);
754 case CPDF_AAction::PageInvisible:
755 pContext->OnPage_OutView(pDocument);
762 CFX_WideString csInfo;
763 FX_BOOL bRet = pContext->RunScript(script, csInfo);
766 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo);
769 pRuntime->ReleaseContext(pContext);
773 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument)
775 ASSERT(pDocument != NULL);
777 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
778 ASSERT(pInterForm != NULL);
780 if (pInterForm->DoAction_Hide(action))
782 pDocument->SetChangeMark();
789 FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
791 ASSERT(pDocument != NULL);
793 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
794 ASSERT(pInterForm != NULL);
796 return pInterForm->DoAction_SubmitForm(action);
799 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
801 ASSERT(pDocument != NULL);
803 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
804 ASSERT(pInterForm != NULL);
806 if (pInterForm->DoAction_ResetForm(action))
814 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData(const CPDF_Action& action, CPDFSDK_Document* pDocument)
816 ASSERT(pDocument != NULL);
818 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
819 ASSERT(pInterForm != NULL);
821 if (pInterForm->DoAction_ImportData(action))
823 pDocument->SetChangeMark();
830 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Rendition(const CPDF_Action& action, CPDFSDK_Document* pDocument)
835 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Sound(const CPDF_Action& action, CPDFSDK_Document* pDocument)
840 FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument)