diff options
author | Lei Zhang <thestig@chromium.org> | 2015-08-14 19:24:08 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-08-14 19:24:08 -0700 |
commit | bdf72c353af5b8a34ef5efdeddfff36d2089a158 (patch) | |
tree | 34258c3019152b41bbfd8f3332683dbc25c0c9da /fpdfsdk/src/fpdfformfill.cpp | |
parent | 88f0bafb4163d297b51055124d4d35b769905216 (diff) | |
download | pdfium-bdf72c353af5b8a34ef5efdeddfff36d2089a158.tar.xz |
Merge to XFA: Add new public APIs to find the z-order for links and widgets.
- Implement FPDFLink_GetLinkZOrderAtPoint().
- Implement FPDFPage_FormFieldZOrderAtPoint().
- Mark FPDPage_HasFormFieldAtPoint() as deprecated.
- Modify CPDF_LinkList and CPDF_InterForm to support new APIs.
- Clean up dead code in CPDF_LinkList and CPDF_InterForm.
BUG=chromium:515837
R=jun_fang@foxitsoftware.com, tsepez@chromium.org
Review URL: https://codereview.chromium.org/1278053004 .
(cherry picked from commit 24fbf134d43a7ec4226de3db601f0a617bbe428b)
Review URL: https://codereview.chromium.org/1295893005 .
Diffstat (limited to 'fpdfsdk/src/fpdfformfill.cpp')
-rw-r--r-- | fpdfsdk/src/fpdfformfill.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp index abb8026a7f..51d90b7eab 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -37,32 +37,26 @@ CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, } // namespace -DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y) { +DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y) { if (!page || !hHandle) return -1; + CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); if (pPage) { - CPDF_InterForm* pInterForm = NULL; - pInterForm = new CPDF_InterForm(pPage->m_pDocument, FALSE); - if (!pInterForm) + CPDF_InterForm interform(pPage->m_pDocument, FALSE); + CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( + pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr); + if (!pFormCtrl) return -1; - CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( - pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); - if (!pFormCtrl) { - delete pInterForm; - return -1; - } + CPDF_FormField* pFormField = pFormCtrl->GetField(); - if (!pFormField) { - delete pInterForm; + if (!pFormField) return -1; - } int nType = pFormField->GetFieldType(); - delete pInterForm; return nType; } @@ -109,6 +103,28 @@ DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, return -1; } +DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y) { + return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y); +} + +DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y) { + if (!page || !hHandle) + return -1; + + CPDF_Page* pPage = (CPDF_Page*)page; + CPDF_InterForm interform(pPage->m_pDocument, FALSE); + int z_order = -1; + (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, + &z_order); + return z_order; +} + DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) { |