Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: fpdfsdk/src/fpdfformfill.cpp

Issue 1278053004: Add new public APIs to find the z-order for links and widgets. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | fpdfsdk/src/fpdfview_c_api_test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../third_party/base/nonstd_unique_ptr.h" 9 #include "../../third_party/base/nonstd_unique_ptr.h"
10 #include "../include/fsdk_define.h" 10 #include "../include/fsdk_define.h"
(...skipping 16 matching lines...) Expand all
27 FPDF_PAGE page) { 27 FPDF_PAGE page) {
28 if (!page) 28 if (!page)
29 return nullptr; 29 return nullptr;
30 30
31 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 31 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
32 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr; 32 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, 37 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
38 FPDF_PAGE page, 38 FPDF_PAGE page,
39 double page_x, 39 double page_x,
40 double page_y) { 40 double page_y) {
41 if (!page || !hHandle) 41 if (!page || !hHandle)
42 return -1; 42 return -1;
43
43 CPDF_Page* pPage = (CPDF_Page*)page; 44 CPDF_Page* pPage = (CPDF_Page*)page;
44 45 CPDF_InterForm interform(pPage->m_pDocument, FALSE);
45 nonstd::unique_ptr<CPDF_InterForm> pInterForm( 46 CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
46 new CPDF_InterForm(pPage->m_pDocument, FALSE)); 47 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr);
47 CPDF_FormControl* pFormCtrl =
48 pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
49 if (!pFormCtrl) 48 if (!pFormCtrl)
50 return -1; 49 return -1;
51 50
52 CPDF_FormField* pFormField = pFormCtrl->GetField(); 51 CPDF_FormField* pFormField = pFormCtrl->GetField();
53 if (!pFormField) 52 if (!pFormField)
54 return -1; 53 return -1;
55 54
56 return pFormField->GetFieldType(); 55 return pFormField->GetFieldType();
57 } 56 }
58 57
58 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
59 FPDF_PAGE page,
60 double page_x,
61 double page_y) {
62 return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y);
63 }
64
65 DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
66 FPDF_PAGE page,
67 double page_x,
68 double page_y) {
69 if (!page || !hHandle)
70 return -1;
71
72 CPDF_Page* pPage = (CPDF_Page*)page;
73 CPDF_InterForm interform(pPage->m_pDocument, FALSE);
74 int z_order = -1;
75 (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y,
76 &z_order);
77 return z_order;
78 }
79
59 DLLEXPORT FPDF_FORMHANDLE STDCALL 80 DLLEXPORT FPDF_FORMHANDLE STDCALL
60 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, 81 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
61 FPDF_FORMFILLINFO* formInfo) { 82 FPDF_FORMFILLINFO* formInfo) {
62 if (!document || !formInfo || formInfo->version != 1) 83 if (!document || !formInfo || formInfo->version != 1)
63 return nullptr; 84 return nullptr;
64 85
65 CPDF_Document* pDocument = (CPDF_Document*)document; 86 CPDF_Document* pDocument = (CPDF_Document*)document;
66 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); 87 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo);
67 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv)); 88 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
68 return pEnv; 89 return pEnv;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 342 }
322 } else { 343 } else {
323 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); 344 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
324 if (bExistCAAction) { 345 if (bExistCAAction) {
325 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 346 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
326 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 347 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
327 } 348 }
328 } 349 }
329 } 350 }
330 } 351 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | fpdfsdk/src/fpdfview_c_api_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698