bool CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus( CPDFSDK_Annot::ObservedPtr* pOldAnnot, CPDFSDK_Annot::ObservedPtr* pNewAnnot) { CXFA_FFWidgetHandler* pWidgetHandler = nullptr; if (*pOldAnnot) pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get()); else if (*pNewAnnot) pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get()); if (!pWidgetHandler) return true; CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr; if (!hWidget) return true; CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); if (!pXFAPageView) return true; bool bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) bRet = true; return bRet; }
FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot) { CXFA_FFWidgetHandler* pWidgetHandler = nullptr; if (pOldAnnot) pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); else if (pNewAnnot) pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); if (pWidgetHandler) { FX_BOOL bRet = TRUE; CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr; if (hWidget) { CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); if (pXFAPageView) { bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) bRet = TRUE; } } return bRet; } return TRUE; }
void CXFA_FFDocView::OnPageEvent(IXFA_LayoutPage* pSender, XFA_PAGEEVENT eEvent, int32_t iPageIndex) { CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender); if (eEvent == XFA_PAGEEVENT_PageRemoved) { m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, XFA_PAGEVIEWEVENT_PostRemoved); return; } m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, XFA_PAGEVIEWEVENT_PostAdded); pFFPageView->LoadPageView(); }
void CXFA_FFDocView::OnPageEvent(IXFA_LayoutPage* pSender, XFA_PAGEEVENT eEvent, int32_t iPageIndex) { FX_BOOL bNofify = m_iStatus >= XFA_DOCVIEW_LAYOUTSTATUS_End; CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender); if (eEvent == XFA_PAGEEVENT_PageRemoved) { if (bNofify) { m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, XFA_PAGEVIEWEVENT_PostRemoved); } } else if (eEvent == XFA_PAGEEVENT_PageAdded) { if (bNofify) { m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, XFA_PAGEVIEWEVENT_PostAdded); pFFPageView->LoadPageView(); } } }
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); 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; CXFA_FFPageView* pPageView = pXFAPage->GetXFAPageView(); if (!pPageView) return -1; CXFA_FFDocView* pDocView = pPageView->GetDocView(); if (!pDocView) return -1; CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return -1; std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, XFA_WidgetStatus_Viewable)); if (!pWidgetIterator) return -1; CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); while (pXFAAnnot) { CFX_RectF rcBBox; pXFAAnnot->GetBBox(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; }