From 40870db0aadef4e145fd3b2b95fa5a083afb3161 Mon Sep 17 00:00:00 2001 From: Diana Gage Date: Wed, 19 Jul 2017 18:16:03 -0700 Subject: Add FPDFAnnot_GetFormFieldAtPoint() and embedder tests. Given a point on a page, this method returns the interactive form annotation whose rectangle contains that point. If there is no such annotation, nullptr is returned. FPDFPage_CloseAnnot() must be called after the annotation this method returns is no longer needed. The tests for this method use the returned annotation to check its interactive form annotation flags via FPDFAnnot_GetFormFieldFlags(). BUG=chromium:59266 Change-Id: I8728792bea5367c172e08fdb6bae83eafb70eb68 Reviewed-on: https://pdfium-review.googlesource.com/7970 Commit-Queue: Diana Gage Reviewed-by: Lei Zhang --- fpdfsdk/fpdfannot.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'fpdfsdk/fpdfannot.cpp') diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index f3a9ea1b72..fcbed5c2ce 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -804,3 +804,22 @@ DLLEXPORT int STDCALL FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, CPDF_FormField* pFormField = interform.GetFieldByDict(pAnnotDict); return pFormField ? pFormField->GetFieldFlags() : FPDF_FORMFLAG_NONE; } + +DLLEXPORT FPDF_ANNOTATION STDCALL +FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y) { + CPDF_Page* pPage = CPDFPageFromFPDFPage(page); + if (!hHandle || !pPage) + return nullptr; + + CPDF_InterForm interform(pPage->m_pDocument.Get()); + int annot_index = -1; + CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( + pPage, CFX_PointF(static_cast(page_x), static_cast(page_y)), + &annot_index); + if (!pFormCtrl || annot_index == -1) + return nullptr; + return FPDFPage_GetAnnot(page, annot_index); +} -- cgit v1.2.3