OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../public/fpdf_formfill.h" | 7 #include "../../public/fpdf_formfill.h" |
8 #include "../../public/fpdfview.h" | 8 #include "../../public/fpdfview.h" |
9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 FPDF_PAGE page) { | 30 FPDF_PAGE page) { |
31 if (!page) | 31 if (!page) |
32 return nullptr; | 32 return nullptr; |
33 | 33 |
34 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 34 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
35 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; | 35 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, | 40 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
41 FPDF_PAGE page, | 41 FPDF_PAGE page, |
42 double page_x, | 42 double page_x, |
43 double page_y) { | 43 double page_y) { |
44 if (!page || !hHandle) | 44 if (!page || !hHandle) |
45 return -1; | 45 return -1; |
| 46 |
46 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | 47 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); |
47 if (pPage) { | 48 if (pPage) { |
48 CPDF_InterForm* pInterForm = NULL; | 49 CPDF_InterForm interform(pPage->m_pDocument, FALSE); |
49 pInterForm = new CPDF_InterForm(pPage->m_pDocument, FALSE); | 50 CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( |
50 if (!pInterForm) | 51 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr); |
| 52 if (!pFormCtrl) |
51 return -1; | 53 return -1; |
52 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( | 54 |
53 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); | 55 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
54 if (!pFormCtrl) { | 56 if (!pFormField) |
55 delete pInterForm; | |
56 return -1; | 57 return -1; |
57 } | |
58 CPDF_FormField* pFormField = pFormCtrl->GetField(); | |
59 if (!pFormField) { | |
60 delete pInterForm; | |
61 return -1; | |
62 } | |
63 | 58 |
64 int nType = pFormField->GetFieldType(); | 59 int nType = pFormField->GetFieldType(); |
65 delete pInterForm; | |
66 return nType; | 60 return nType; |
67 } | 61 } |
68 | 62 |
69 IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); | 63 IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); |
70 if (pPageView) { | 64 if (pPageView) { |
71 IXFA_WidgetHandler* pWidgetHandler = NULL; | 65 IXFA_WidgetHandler* pWidgetHandler = NULL; |
72 IXFA_DocView* pDocView = pPageView->GetDocView(); | 66 IXFA_DocView* pDocView = pPageView->GetDocView(); |
73 if (!pDocView) | 67 if (!pDocView) |
74 return -1; | 68 return -1; |
75 | 69 |
(...skipping 26 matching lines...) Expand all Loading... |
102 } | 96 } |
103 pXFAAnnot = pWidgetIterator->MoveToNext(); | 97 pXFAAnnot = pWidgetIterator->MoveToNext(); |
104 } | 98 } |
105 | 99 |
106 pWidgetIterator->Release(); | 100 pWidgetIterator->Release(); |
107 } | 101 } |
108 | 102 |
109 return -1; | 103 return -1; |
110 } | 104 } |
111 | 105 |
| 106 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 107 FPDF_PAGE page, |
| 108 double page_x, |
| 109 double page_y) { |
| 110 return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y); |
| 111 } |
| 112 |
| 113 DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, |
| 114 FPDF_PAGE page, |
| 115 double page_x, |
| 116 double page_y) { |
| 117 if (!page || !hHandle) |
| 118 return -1; |
| 119 |
| 120 CPDF_Page* pPage = (CPDF_Page*)page; |
| 121 CPDF_InterForm interform(pPage->m_pDocument, FALSE); |
| 122 int z_order = -1; |
| 123 (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, |
| 124 &z_order); |
| 125 return z_order; |
| 126 } |
| 127 |
112 DLLEXPORT FPDF_FORMHANDLE STDCALL | 128 DLLEXPORT FPDF_FORMHANDLE STDCALL |
113 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, | 129 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, |
114 FPDF_FORMFILLINFO* formInfo) { | 130 FPDF_FORMFILLINFO* formInfo) { |
115 if (!document || !formInfo || formInfo->version != 2) | 131 if (!document || !formInfo || formInfo->version != 2) |
116 return nullptr; | 132 return nullptr; |
117 | 133 |
118 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 134 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
119 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); | 135 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); |
120 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); | 136 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); |
121 | 137 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 674 } |
659 } else { | 675 } else { |
660 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); | 676 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); |
661 if (bExistCAAction) { | 677 if (bExistCAAction) { |
662 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); | 678 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
663 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); | 679 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); |
664 } | 680 } |
665 } | 681 } |
666 } | 682 } |
667 } | 683 } |
OLD | NEW |