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; }
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; }