FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point) { if (!pPageView || !pAnnot) return FALSE; CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); if (!pSDKDoc) return FALSE; CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); if (!pDoc) return FALSE; IXFA_DocView* pDocView = pDoc->GetXFADocView(); if (!pDocView) return FALSE; IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return FALSE; FX_DWORD dwHitTest = pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); return (dwHitTest != FWL_WGTHITTEST_Unknown); }
void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, FX_DWORD dwFlags) { ASSERT(pPageView != NULL); ASSERT(pAnnot != NULL); CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); ASSERT(pSDKDoc != NULL); IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); CFX_Graphics gs; gs.Create(pDevice); CFX_Matrix mt; mt = *(CFX_Matrix*)pUser2Device; FX_BOOL bIsHighlight = FALSE; if (pSDKDoc->GetFocusAnnot() != pAnnot) bIsHighlight = TRUE; pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); // to do highlight and shadow }
CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot != NULL); IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); CFX_RectF rcBBox; XFA_ELEMENT eType = pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType(); if (eType == XFA_ELEMENT_Signature) pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, XFA_WIDGETSTATUS_Visible, TRUE); else pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.left -= 1.0f; rcWidget.right += 1.0f; rcWidget.bottom -= 1.0f; rcWidget.top += 1.0f; return rcWidget; }
FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot) { IXFA_WidgetHandler* pWidgetHandler = NULL; if (pOldAnnot) pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); else if (pNewAnnot) pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); if (pWidgetHandler) { FX_BOOL bRet = TRUE; IXFA_Widget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL; if (hWidget) { IXFA_PageView* pXFAPageView = pWidgetHandler->GetPageView(hWidget); if (pXFAPageView) { bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) bRet = TRUE; } } return bRet; } return TRUE; }
FX_BOOL _SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) { if (!pDocument) return FALSE; if (pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA) return TRUE; IXFA_DocView* pXFADocView = pDocument->GetXFADocView(); if (NULL == pXFADocView) return FALSE; IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler(); CXFA_WidgetAcc* pWidgetAcc = NULL; IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIterator(); pWidgetAcc = pWidgetAccIterator->MoveToNext(); while (pWidgetAcc) { CXFA_EventParam preParam; preParam.m_eType = XFA_EVENT_PostSave; pWidgetHander->ProcessEvent(pWidgetAcc, &preParam); pWidgetAcc = pWidgetAccIterator->MoveToNext(); } pWidgetAccIterator->Release(); pXFADocView->UpdateDocView(); pDocument->_ClearChangeMark(); return TRUE; }
void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) { if (!pPageView || !pAnnot) return; IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget()); }
FX_BOOL CPDFSDK_XFAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags) { if (!pAnnot) return FALSE; IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); FX_BOOL bRet = FALSE; bRet = pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, GetFWLFlags(nFlags)); return bRet; }
FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) { if (!pAnnot) return FALSE; IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); FX_BOOL bRet = FALSE; bRet = pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, GetFWLFlags(nFlag)); return bRet; }
FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) { if (!pPageView || !pAnnot) return FALSE; IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); ASSERT(pWidgetHandler != NULL); FX_BOOL bRet = FALSE; bRet = pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y); return bRet; }
void CScript_EventPseudoModel::Script_EventPseudoModel_Emit( CFXJSE_Arguments* pArguments) { IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); if (!pScriptContext) { return; } CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); if (!pEventParam) { return; } IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); if (!pNotify) { return; } IXFA_WidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); if (!pWidgetHandler) { return; } pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); }
FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList) { if (pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA) return TRUE; IXFA_DocView* pXFADocView = pDocument->GetXFADocView(); if (NULL == pXFADocView) return TRUE; IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler(); CXFA_WidgetAcc* pWidgetAcc = NULL; IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIterator(); pWidgetAcc = pWidgetAccIterator->MoveToNext(); while (pWidgetAcc) { CXFA_EventParam preParam; preParam.m_eType = XFA_EVENT_PreSave; pWidgetHander->ProcessEvent(pWidgetAcc, &preParam); pWidgetAcc = pWidgetAccIterator->MoveToNext(); } pWidgetAccIterator->Release(); pXFADocView->UpdateDocView(); return _SaveXFADocumentData(pDocument, fileList); }
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) { if (!hHandle) return -1; CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (pPage) { CPDF_InterForm interform(pPage->m_pDocument, FALSE); CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x), static_cast<FX_FLOAT>(page_y), nullptr); if (!pFormCtrl) return -1; CPDF_FormField* pFormField = pFormCtrl->GetField(); return pFormField ? pFormField->GetFieldType() : -1; } #ifdef PDF_ENABLE_XFA CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page); if (!pXFAPage) return -1; IXFA_PageView* pPageView = pXFAPage->GetXFAPageView(); if (!pPageView) return -1; IXFA_DocView* pDocView = pPageView->GetDocView(); if (!pDocView) return -1; IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return -1; std::unique_ptr<IXFA_WidgetIterator, ReleaseDeleter<IXFA_WidgetIterator>> pWidgetIterator(pPageView->CreateWidgetIterator( XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_AllType)); if (!pWidgetIterator) return -1; IXFA_Widget* pXFAAnnot = pWidgetIterator->MoveToNext(); while (pXFAAnnot) { CFX_RectF rcBBox; pWidgetHandler->GetBBox(pXFAAnnot, rcBBox, 0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.left -= 1.0f; rcWidget.right += 1.0f; rcWidget.bottom -= 1.0f; rcWidget.top += 1.0f; if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), static_cast<FX_FLOAT>(page_y))) { return FPDF_FORMFIELD_XFA; } pXFAAnnot = pWidgetIterator->MoveToNext(); } #endif // PDF_ENABLE_XFA return -1; }