void CPDFSDK_Annot::SetAction(const CPDF_Action& action) { ASSERT(action); if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A"))) { CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); CPDF_Dictionary* pDict = action.GetDict(); if (pDict && pDict->GetObjNum() == 0) { pDoc->AddIndirectObject(pDict); } m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, pDict->GetObjNum()); } }
FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data, CFX_PtrList& list) { ASSERT(pDocument != NULL); CPDF_Dictionary* pDict = action.GetDict(); if (list.Find(pDict)) return FALSE; list.AddTail(pDict); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if (pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunFieldJavaScript(pDocument, pFormField, type, data, swJS); if (!IsValidField(pDocument, pFormField->GetFieldDict())) return FALSE; } } } else { DoAction_NoJs(action, pDocument); } for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) return FALSE; } return TRUE; }
FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CFX_PtrList& list) { ASSERT(pDocument != NULL); if (list.Find((CPDF_Dictionary*)action)) return FALSE; list.AddTail((CPDF_Dictionary*)action); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if(pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunDocumentPageJavaScript(pDocument, type, swJS); } } } else { DoAction_NoJs(action, pDocument/*, pDocView*/); } if (!IsValidDocView(pDocument/*, pDocView*/)) return FALSE; for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteDocumentPageAction(subaction, type, pDocument,/* pDocView,*/ list)) return FALSE; } return TRUE; }
FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data, std::set<CPDF_Dictionary*>* visited) { CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return FALSE; visited->insert(pDict); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if (pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunFieldJavaScript(pDocument, pFormField, type, data, swJS); if (!IsValidField(pDocument, pFormField->GetFieldDict())) return FALSE; } } } else { DoAction_NoJs(action, pDocument); } for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, visited)) return FALSE; } return TRUE; }
FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { CFX_WideString sDestination = action.GetFilePath(); if (sDestination.IsEmpty()) return FALSE; CPDF_Dictionary* pActionDict = action.GetDict(); if (pActionDict->KeyExist("Fields")) { CPDF_ActionFields af(&action); uint32_t dwFlags = action.GetFlags(); std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); if (!fields.empty()) { bool bIncludeOrExclude = !(dwFlags & 0x01); if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) return FALSE; return SubmitFields(sDestination, fields, bIncludeOrExclude, false); } } if (m_pInterForm->CheckRequiredFields(nullptr, true)) return FALSE; return SubmitForm(sDestination, FALSE); }
void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument) { ASSERT(pDocument != NULL); switch (action.GetType()) { case CPDF_Action::GoTo: DoAction_GoTo(pDocument, action); break; case CPDF_Action::GoToR: DoAction_GoToR(pDocument, action); break; case CPDF_Action::GoToE: break; case CPDF_Action::Launch: DoAction_Launch(pDocument, action); break; case CPDF_Action::Thread: break; case CPDF_Action::URI: DoAction_URI(pDocument, action); break; case CPDF_Action::Sound: break; case CPDF_Action::Movie: break; case CPDF_Action::Hide: if (m_pFormActionHandler) { m_pFormActionHandler->DoAction_Hide(action, pDocument); } break; case CPDF_Action::Named: DoAction_Named(pDocument, action); break; case CPDF_Action::SubmitForm: if (m_pFormActionHandler) { m_pFormActionHandler->DoAction_SubmitForm(action, pDocument); } break; case CPDF_Action::ResetForm: if (m_pFormActionHandler) { m_pFormActionHandler->DoAction_ResetForm(action, pDocument); } break; case CPDF_Action::ImportData: if (m_pFormActionHandler) { m_pFormActionHandler->DoAction_ImportData(action, pDocument); } break; case CPDF_Action::JavaScript: ASSERT(FALSE); break; case CPDF_Action::SetOCGState: DoAction_SetOCGState(pDocument, action); break; case CPDF_Action::Rendition: break; case CPDF_Action::Trans: break; case CPDF_Action::GoTo3DView: break; default: break; } }
FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,/* CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list) { ASSERT(pDocument != NULL); if (list.Find((CPDF_Dictionary*)action)) return FALSE; list.AddTail((CPDF_Dictionary*)action); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv); if (action.GetType() == CPDF_Action::JavaScript) { if(pEnv->IsJSInitiated()) { CFX_WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); ASSERT(pRuntime != NULL); pRuntime->SetReaderDocument(pDocument); IFXJS_Context* pContext = pRuntime->NewContext(); ASSERT(pContext != NULL); // switch (type) // { // case CPDF_AAction::CursorEnter: // pContext->OnScreen_MouseEnter(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::CursorExit: // pContext->OnScreen_MouseExit(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::ButtonDown: // pContext->OnScreen_MouseDown(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::ButtonUp: // pContext->OnScreen_MouseUp(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::GetFocus: // pContext->OnScreen_Focus(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::LoseFocus: // pContext->OnScreen_Blur(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::PageOpen: // pContext->OnScreen_Open(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::PageClose: // pContext->OnScreen_Close(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::PageVisible: // pContext->OnScreen_InView(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // case CPDF_AAction::PageInvisible: // pContext->OnScreen_OutView(IsCTRLpressed(), IsSHIFTpressed(), pScreen); // break; // default: // ASSERT(FALSE); // break; // } CFX_WideString csInfo; FX_BOOL bRet = pContext->RunScript(swJS, csInfo); if (!bRet) { //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); } pRuntime->ReleaseContext(pContext); } } } else { DoAction_NoJs(action, pDocument/*, pDocView*/); } // if (!IsValidDocView(pDocument, pDocView)) // return FALSE; for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++) { CPDF_Action subaction = action.GetSubAction(i); if (!ExecuteScreenAction(subaction, type, pDocument,/* pDocView,*/ pScreen, list)) return FALSE; } return TRUE; }