blob: 3170627cd5880583de8467728de82a20fa825473 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Lei Zhangb4e7f302015-11-06 15:52:32 -08007#include "public/fpdf_formfill.h"
8
Lei Zhangaa8bf7e2015-12-24 19:13:32 -08009#include <memory>
Tom Sepezab277682016-02-17 10:07:21 -080010#include <vector>
Lei Zhangaa8bf7e2015-12-24 19:13:32 -080011
dsinclair41872fa2016-10-04 11:29:35 -070012#include "core/fpdfapi/page/cpdf_page.h"
dsinclair488b7ad2016-10-04 11:55:50 -070013#include "core/fpdfapi/parser/cpdf_document.h"
dsinclair69d9c682016-10-04 12:18:35 -070014#include "core/fpdfapi/render/cpdf_renderoptions.h"
dsinclair1727aee2016-09-29 13:12:56 -070015#include "core/fpdfdoc/cpdf_formcontrol.h"
16#include "core/fpdfdoc/cpdf_formfield.h"
17#include "core/fpdfdoc/cpdf_interform.h"
18#include "core/fpdfdoc/cpdf_occontext.h"
Dan Sinclaira5085d42017-05-11 16:26:50 -040019#include "core/fxge/cfx_defaultrenderdevice.h"
Dan Sinclair7d125322018-03-28 18:49:34 +000020#include "fpdfsdk/cpdfsdk_actionhandler.h"
dsinclair735606d2016-10-05 15:47:02 -070021#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
Dan Sinclair00d47a62018-03-28 18:39:04 +000022#include "fpdfsdk/cpdfsdk_helpers.h"
dsinclair114e46a2016-09-29 17:18:21 -070023#include "fpdfsdk/cpdfsdk_interform.h"
24#include "fpdfsdk/cpdfsdk_pageview.h"
Lei Zhangb4e7f302015-11-06 15:52:32 -080025#include "public/fpdfview.h"
tsepez36eb4bd2016-10-03 15:24:27 -070026#include "third_party/base/ptr_util.h"
Tom Sepezab277682016-02-17 10:07:21 -080027#include "third_party/base/stl_util.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070028
Tom Sepez40e9ff32015-11-30 12:39:54 -080029#ifdef PDF_ENABLE_XFA
dsinclair521b7502016-11-02 13:02:28 -070030#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
dsinclair4d29e782016-10-04 14:02:47 -070031#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040032#include "xfa/fxfa/cxfa_ffdocview.h"
33#include "xfa/fxfa/cxfa_ffpageview.h"
34#include "xfa/fxfa/cxfa_ffwidget.h"
Dan Sinclaircdba7472017-03-23 09:17:10 -040035
Ryan Harrison854d71c2017-10-18 12:28:14 -040036static_assert(static_cast<int>(FormType::kNone) == FORMTYPE_NONE,
37 "None form types must match");
38static_assert(static_cast<int>(FormType::kAcroForm) == FORMTYPE_ACRO_FORM,
39 "AcroForm form types must match");
40static_assert(static_cast<int>(FormType::kXFAFull) == FORMTYPE_XFA_FULL,
41 "XFA full form types must match");
42static_assert(static_cast<int>(FormType::kXFAForeground) ==
43 FORMTYPE_XFA_FOREGROUND,
44 "XFA foreground form types must match");
Tom Sepez40e9ff32015-11-30 12:39:54 -080045#endif // PDF_ENABLE_XFA
46
Ryan Harrison9baf31f2018-01-12 18:36:30 +000047static_assert(static_cast<int>(FormFieldType::kUnknown) ==
48 FPDF_FORMFIELD_UNKNOWN,
49 "Unknown form field types must match");
50static_assert(static_cast<int>(FormFieldType::kPushButton) ==
51 FPDF_FORMFIELD_PUSHBUTTON,
52 "PushButton form field types must match");
53static_assert(static_cast<int>(FormFieldType::kCheckBox) ==
54 FPDF_FORMFIELD_CHECKBOX,
55 "CheckBox form field types must match");
56static_assert(static_cast<int>(FormFieldType::kRadioButton) ==
57 FPDF_FORMFIELD_RADIOBUTTON,
58 "RadioButton form field types must match");
59static_assert(static_cast<int>(FormFieldType::kComboBox) ==
60 FPDF_FORMFIELD_COMBOBOX,
61 "ComboBox form field types must match");
62static_assert(static_cast<int>(FormFieldType::kListBox) ==
63 FPDF_FORMFIELD_LISTBOX,
64 "ListBox form field types must match");
65static_assert(static_cast<int>(FormFieldType::kTextField) ==
66 FPDF_FORMFIELD_TEXTFIELD,
67 "TextField form field types must match");
68static_assert(static_cast<int>(FormFieldType::kSignature) ==
69 FPDF_FORMFIELD_SIGNATURE,
70 "Signature form field types must match");
71#ifdef PDF_ENABLE_XFA
72static_assert(static_cast<int>(FormFieldType::kXFA) == FPDF_FORMFIELD_XFA,
73 "XFA form field types must match");
Ryan Harrison2056fac2018-01-16 16:06:45 +000074static_assert(static_cast<int>(FormFieldType::kXFA_CheckBox) ==
75 FPDF_FORMFIELD_XFA_CHECKBOX,
76 "XFA CheckBox form field types must match");
77static_assert(static_cast<int>(FormFieldType::kXFA_ComboBox) ==
78 FPDF_FORMFIELD_XFA_COMBOBOX,
79 "XFA ComboBox form field types must match");
80static_assert(static_cast<int>(FormFieldType::kXFA_ImageField) ==
81 FPDF_FORMFIELD_XFA_IMAGEFIELD,
82 "XFA ImageField form field types must match");
83static_assert(static_cast<int>(FormFieldType::kXFA_ListBox) ==
84 FPDF_FORMFIELD_XFA_LISTBOX,
85 "XFA ListBox form field types must match");
86static_assert(static_cast<int>(FormFieldType::kXFA_PushButton) ==
87 FPDF_FORMFIELD_XFA_PUSHBUTTON,
88 "XFA PushButton form field types must match");
89static_assert(static_cast<int>(FormFieldType::kXFA_Signature) ==
90 FPDF_FORMFIELD_XFA_SIGNATURE,
91 "XFA Signature form field types must match");
92static_assert(static_cast<int>(FormFieldType::kXFA_TextField) ==
93 FPDF_FORMFIELD_XFA_TEXTFIELD,
94 "XFA TextField form field types must match");
Ryan Harrison9baf31f2018-01-12 18:36:30 +000095#endif // PDF_ENABLE_XFA
96static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT,
97 "Number of form field types must match");
98
Tom Sepezdcbc02f2015-07-17 09:16:17 -070099namespace {
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100
dsinclair735606d2016-10-05 15:47:02 -0700101CPDFSDK_FormFillEnvironment* HandleToCPDFSDKEnvironment(
102 FPDF_FORMHANDLE handle) {
103 return static_cast<CPDFSDK_FormFillEnvironment*>(handle);
dsinclair79db6092016-09-14 07:27:21 -0700104}
105
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700106CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700107 CPDFSDK_FormFillEnvironment* pFormFillEnv =
108 HandleToCPDFSDKEnvironment(hHandle);
dsinclair7cbe68e2016-10-12 11:56:23 -0700109 return pFormFillEnv ? pFormFillEnv->GetInterForm() : nullptr;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700110}
Bo Xufdc00a72014-10-28 23:03:33 -0700111
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
113 FPDF_PAGE page) {
Tom Sepez540c4362015-11-24 13:33:57 -0800114 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
115 if (!pPage)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 return nullptr;
Tom Sepez0b133982015-07-28 11:23:22 -0700117
dsinclairf3fbe832016-10-11 13:08:04 -0700118 CPDFSDK_FormFillEnvironment* pFormFillEnv =
119 HandleToCPDFSDKEnvironment(hHandle);
dsinclair7cbe68e2016-10-12 11:56:23 -0700120 return pFormFillEnv ? pFormFillEnv->GetPageView(pPage, true) : nullptr;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700121}
Bo Xufdc00a72014-10-28 23:03:33 -0700122
thestigbefa4502016-05-26 20:15:19 -0700123void FFLCommon(FPDF_FORMHANDLE hHandle,
124 FPDF_BITMAP bitmap,
125 FPDF_RECORDER recorder,
126 FPDF_PAGE page,
127 int start_x,
128 int start_y,
129 int size_x,
130 int size_y,
131 int rotate,
132 int flags) {
133 if (!hHandle)
134 return;
135
136 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
137 if (!pPage)
138 return;
139
jaepark738766e2016-09-02 18:51:44 -0700140#ifdef PDF_ENABLE_XFA
dsinclair521b7502016-11-02 13:02:28 -0700141 CPDFXFA_Context* pContext = pPage->GetContext();
142 if (!pContext)
thestigbefa4502016-05-26 20:15:19 -0700143 return;
dsinclair521b7502016-11-02 13:02:28 -0700144 CPDF_Document* pPDFDoc = pContext->GetPDFDoc();
thestigbefa4502016-05-26 20:15:19 -0700145 if (!pPDFDoc)
146 return;
dsinclairf3fbe832016-10-11 13:08:04 -0700147 CPDFSDK_FormFillEnvironment* pFormFillEnv =
148 HandleToCPDFSDKEnvironment(hHandle);
149 if (!pFormFillEnv)
thestigbefa4502016-05-26 20:15:19 -0700150 return;
151#endif // PDF_ENABLE_XFA
152
Lei Zhangc4242b22018-04-12 15:50:49 +0000153 const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
154 CFX_Matrix matrix = pPage->GetDisplayMatrix(rect, rotate);
thestigbefa4502016-05-26 20:15:19 -0700155
Dan Sinclaira5085d42017-05-11 16:26:50 -0400156 auto pDevice = pdfium::MakeUnique<CFX_DefaultRenderDevice>();
thestigbefa4502016-05-26 20:15:19 -0700157#ifdef _SKIA_SUPPORT_
158 pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
159#endif
Dan Sinclair0b950422017-09-21 15:49:49 -0400160 RetainPtr<CFX_DIBitmap> holder(CFXBitmapFromFPDFBitmap(bitmap));
Tom Sepezf0799fe2017-03-28 09:31:32 -0700161 pDevice->Attach(holder, false, nullptr, false);
Tom Sepez1629f602017-04-21 14:11:26 -0700162 {
163 CFX_RenderDevice::StateRestorer restorer(pDevice.get());
Lei Zhangc4242b22018-04-12 15:50:49 +0000164 pDevice->SetClip_Rect(rect);
thestigbefa4502016-05-26 20:15:19 -0700165
Tom Sepez1629f602017-04-21 14:11:26 -0700166 CPDF_RenderOptions options;
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400167 uint32_t option_flags = options.GetFlags();
Tom Sepez1629f602017-04-21 14:11:26 -0700168 if (flags & FPDF_LCD_TEXT)
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400169 option_flags |= RENDER_CLEARTYPE;
Tom Sepez1629f602017-04-21 14:11:26 -0700170 else
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400171 option_flags &= ~RENDER_CLEARTYPE;
172 options.SetFlags(option_flags);
thestigbefa4502016-05-26 20:15:19 -0700173
Tom Sepez1629f602017-04-21 14:11:26 -0700174 // Grayscale output
Dan Sinclairf55e72e2017-07-13 14:53:28 -0400175 if (flags & FPDF_GRAYSCALE)
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400176 options.SetColorMode(CPDF_RenderOptions::kGray);
Dan Sinclairf55e72e2017-07-13 14:53:28 -0400177
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400178 options.SetDrawAnnots(flags & FPDF_ANNOT);
thestigbefa4502016-05-26 20:15:19 -0700179
jaepark738766e2016-09-02 18:51:44 -0700180#ifdef PDF_ENABLE_XFA
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400181 options.SetOCContext(
182 pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View));
Tom Sepez1629f602017-04-21 14:11:26 -0700183 if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true))
Lei Zhangc4242b22018-04-12 15:50:49 +0000184 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, rect);
jaepark738766e2016-09-02 18:51:44 -0700185#else // PDF_ENABLE_XFA
Dan Sinclair921fe6b2017-10-05 11:14:12 -0400186 options.SetOCContext(pdfium::MakeRetain<CPDF_OCContext>(
187 pPage->m_pDocument.Get(), CPDF_OCContext::View));
Tom Sepez1629f602017-04-21 14:11:26 -0700188 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
189 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
thestigbefa4502016-05-26 20:15:19 -0700190#endif // PDF_ENABLE_XFA
Tom Sepez1629f602017-04-21 14:11:26 -0700191 }
caryclark8f875502016-12-06 13:49:34 -0800192#ifdef _SKIA_SUPPORT_PATHS_
Cary Clark364d18b2017-07-25 10:39:10 -0400193 pDevice->Flush(true);
Tom Sepezf0799fe2017-03-28 09:31:32 -0700194 holder->UnPreMultiply();
caryclark687fbde2016-11-22 12:44:25 -0800195#endif
thestigbefa4502016-05-26 20:15:19 -0700196}
197
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700198} // namespace
Bo Xufdc00a72014-10-28 23:03:33 -0700199
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400200FPDF_EXPORT int FPDF_CALLCONV
201FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
202 FPDF_PAGE page,
203 double page_x,
204 double page_y) {
Tom Sepezdb0be962015-10-16 14:00:21 -0700205 if (!hHandle)
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700206 return -1;
Tom Sepezdb0be962015-10-16 14:00:21 -0700207 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700208 if (pPage) {
Tom Sepez4cb82ee2017-05-22 15:15:30 -0700209 CPDF_InterForm interform(pPage->m_pDocument.Get());
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500210 CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
Dan Sinclair05df0752017-03-14 14:43:42 -0400211 pPage,
212 CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500213 nullptr);
Lei Zhangbdf72c32015-08-14 19:24:08 -0700214 if (!pFormCtrl)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 return -1;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700216 CPDF_FormField* pFormField = pFormCtrl->GetField();
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000217 return pFormField ? static_cast<int>(pFormField->GetFieldType()) : -1;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218 }
219
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800220#ifdef PDF_ENABLE_XFA
221 CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page);
222 if (!pXFAPage)
223 return -1;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700224
dsinclairdf4bc592016-03-31 20:34:43 -0700225 CXFA_FFPageView* pPageView = pXFAPage->GetXFAPageView();
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800226 if (!pPageView)
227 return -1;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700228
dsinclairdf4bc592016-03-31 20:34:43 -0700229 CXFA_FFDocView* pDocView = pPageView->GetDocView();
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800230 if (!pDocView)
231 return -1;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232
dsinclairdf4bc592016-03-31 20:34:43 -0700233 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800234 if (!pWidgetHandler)
235 return -1;
236
tsepezcc4d6d82016-05-16 13:21:03 -0700237 std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator(
dsinclair935d8d52016-05-17 10:32:18 -0700238 pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form,
239 XFA_WidgetStatus_Viewable));
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800240 if (!pWidgetIterator)
241 return -1;
242
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000243 CXFA_FFWidget* pXFAAnnot;
244 while ((pXFAAnnot = pWidgetIterator->MoveToNext()) != nullptr) {
Henrique Nakashima1087ebc2018-02-16 19:31:39 +0000245 if (pXFAAnnot->GetFormFieldType() == FormFieldType::kXFA)
246 continue;
247
248 CFX_RectF rcBBox = pXFAAnnot->GetWidgetRect();
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800249 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
250 rcBBox.top + rcBBox.height);
Lei Zhang1fed5a22017-06-01 11:52:22 -0700251 rcWidget.Inflate(1.0f, 1.0f);
Dan Sinclair05df0752017-03-14 14:43:42 -0400252 if (rcWidget.Contains(CFX_PointF(static_cast<float>(page_x),
253 static_cast<float>(page_y)))) {
Ryan Harrison2056fac2018-01-16 16:06:45 +0000254 return static_cast<int>(pXFAAnnot->GetFormFieldType());
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700256 }
Tom Sepez40e9ff32015-11-30 12:39:54 -0800257#endif // PDF_ENABLE_XFA
Lei Zhang7f9fdde2016-02-22 20:47:13 -0800258 return -1;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700259}
260
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400261FPDF_EXPORT int FPDF_CALLCONV
262FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
263 FPDF_PAGE page,
264 double page_x,
265 double page_y) {
Tom Sepezdb0be962015-10-16 14:00:21 -0700266 if (!hHandle)
Lei Zhangbdf72c32015-08-14 19:24:08 -0700267 return -1;
Tom Sepezdb0be962015-10-16 14:00:21 -0700268 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
269 if (!pPage)
270 return -1;
Tom Sepez4cb82ee2017-05-22 15:15:30 -0700271 CPDF_InterForm interform(pPage->m_pDocument.Get());
Lei Zhangbdf72c32015-08-14 19:24:08 -0700272 int z_order = -1;
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500273 (void)interform.GetControlAtPoint(
Dan Sinclair05df0752017-03-14 14:43:42 -0400274 pPage, CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500275 &z_order);
Lei Zhangbdf72c32015-08-14 19:24:08 -0700276 return z_order;
277}
278
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400279FPDF_EXPORT FPDF_FORMHANDLE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
281 FPDF_FORMFILLINFO* formInfo) {
Tom Sepez40e9ff32015-11-30 12:39:54 -0800282#ifdef PDF_ENABLE_XFA
Tom Sepez540c4362015-11-24 13:33:57 -0800283 const int kRequiredVersion = 2;
Tom Sepez40e9ff32015-11-30 12:39:54 -0800284#else // PDF_ENABLE_XFA
285 const int kRequiredVersion = 1;
286#endif // PDF_ENABLE_XFA
Tom Sepez540c4362015-11-24 13:33:57 -0800287 if (!formInfo || formInfo->version != kRequiredVersion)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700288 return nullptr;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700289
Tom Sepezfe06d512018-05-01 17:25:25 +0000290 auto* pDocument = CPDFDocumentFromFPDFDocument(document);
Tom Sepez540c4362015-11-24 13:33:57 -0800291 if (!pDocument)
292 return nullptr;
293
Tom Sepez40e9ff32015-11-30 12:39:54 -0800294#ifdef PDF_ENABLE_XFA
dsinclair521b7502016-11-02 13:02:28 -0700295 // If the CPDFXFA_Context has a FormFillEnvironment already then we've done
dsinclair8779fa82016-10-12 12:05:44 -0700296 // this and can just return the old Env. Otherwise, we'll end up setting a new
297 // environment into the XFADocument and, that could get weird.
Tom Sepezfe06d512018-05-01 17:25:25 +0000298 auto* pContext = static_cast<CPDFXFA_Context*>(pDocument->GetExtension());
299 if (pContext->GetFormFillEnv())
300 return pContext->GetFormFillEnv();
dsinclaira939bfe2016-09-22 13:18:45 -0700301#endif
302
Tom Sepezda8063f2018-04-30 17:41:49 +0000303 auto pFormFillEnv = pdfium::MakeUnique<CPDFSDK_FormFillEnvironment>(
304 CPDFDocumentFromFPDFDocument(document), formInfo);
dsinclaira939bfe2016-09-22 13:18:45 -0700305
306#ifdef PDF_ENABLE_XFA
Tom Sepezfe06d512018-05-01 17:25:25 +0000307 pContext->SetFormFillEnv(pFormFillEnv.get());
Tom Sepez40e9ff32015-11-30 12:39:54 -0800308#endif // PDF_ENABLE_XFA
dsinclaira939bfe2016-09-22 13:18:45 -0700309
Tom Sepezfe91c6c2017-05-16 15:33:20 -0700310 return pFormFillEnv.release(); // Caller takes ownership.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700311}
312
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400313FPDF_EXPORT void FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700314FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700315 CPDFSDK_FormFillEnvironment* pFormFillEnv =
316 HandleToCPDFSDKEnvironment(hHandle);
Lei Zhang1fed5a22017-06-01 11:52:22 -0700317 if (!pFormFillEnv)
318 return;
dsinclaira939bfe2016-09-22 13:18:45 -0700319
Tom Sepez40e9ff32015-11-30 12:39:54 -0800320#ifdef PDF_ENABLE_XFA
dsinclair21161052016-10-05 15:46:15 -0700321 // Reset the focused annotations and remove the SDK document from the
322 // XFA document.
dsinclair7cbe68e2016-10-12 11:56:23 -0700323 pFormFillEnv->ClearAllFocusedAnnots();
dsinclairf3fbe832016-10-11 13:08:04 -0700324 // If the document was closed first, it's possible the XFA document
325 // is now a nullptr.
dsinclair521b7502016-11-02 13:02:28 -0700326 if (pFormFillEnv->GetXFAContext())
327 pFormFillEnv->GetXFAContext()->SetFormFillEnv(nullptr);
Tom Sepez40e9ff32015-11-30 12:39:54 -0800328#endif // PDF_ENABLE_XFA
dsinclairf3fbe832016-10-11 13:08:04 -0700329 delete pFormFillEnv;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700330}
331
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400332FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
333 FPDF_PAGE page,
334 int modifier,
335 double page_x,
336 double page_y) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700337 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
338 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700339 return false;
Dan Sinclairf528eee2017-02-14 11:52:07 -0500340 return pPageView->OnMouseMove(CFX_PointF(page_x, page_y), modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700341}
342
Lei Zhang63b01262017-08-31 08:54:46 -0700343FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnFocus(FPDF_FORMHANDLE hHandle,
344 FPDF_PAGE page,
345 int modifier,
346 double page_x,
347 double page_y) {
348 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
349 if (!pPageView)
350 return false;
351 return pPageView->OnFocus(CFX_PointF(page_x, page_y), modifier);
352}
353
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400354FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
355 FPDF_PAGE page,
356 int modifier,
357 double page_x,
358 double page_y) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700359 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
360 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700361 return false;
Dan Sinclairf528eee2017-02-14 11:52:07 -0500362 return pPageView->OnLButtonDown(CFX_PointF(page_x, page_y), modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700363}
364
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400365FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
366 FPDF_PAGE page,
367 int modifier,
368 double page_x,
369 double page_y) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700370 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
371 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700372 return false;
Lei Zhang1fed5a22017-06-01 11:52:22 -0700373 return pPageView->OnLButtonUp(CFX_PointF(page_x, page_y), modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700374}
375
Tom Sepez51da0932015-11-25 16:05:49 -0800376#ifdef PDF_ENABLE_XFA
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400377FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
378 FPDF_PAGE page,
379 int modifier,
380 double page_x,
381 double page_y) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700382 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
383 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700384 return false;
Dan Sinclairf528eee2017-02-14 11:52:07 -0500385 return pPageView->OnRButtonDown(CFX_PointF(page_x, page_y), modifier);
Bo Xufdc00a72014-10-28 23:03:33 -0700386}
387
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400388FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
389 FPDF_PAGE page,
390 int modifier,
391 double page_x,
392 double page_y) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700393 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
394 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700395 return false;
Lei Zhang1fed5a22017-06-01 11:52:22 -0700396 return pPageView->OnRButtonUp(CFX_PointF(page_x, page_y), modifier);
Bo Xufdc00a72014-10-28 23:03:33 -0700397}
Tom Sepez40e9ff32015-11-30 12:39:54 -0800398#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700399
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400400FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
401 FPDF_PAGE page,
402 int nKeyCode,
403 int modifier) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700404 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
405 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700406 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700407 return pPageView->OnKeyDown(nKeyCode, modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700408}
409
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400410FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
411 FPDF_PAGE page,
412 int nKeyCode,
413 int modifier) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
415 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700416 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700417 return pPageView->OnKeyUp(nKeyCode, modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418}
419
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400420FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle,
421 FPDF_PAGE page,
422 int nChar,
423 int modifier) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700424 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
425 if (!pPageView)
tsepez4cf55152016-11-02 14:37:54 -0700426 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700427 return pPageView->OnChar(nChar, modifier);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700428}
429
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400430FPDF_EXPORT unsigned long FPDF_CALLCONV
Lei Zhanga4c7ac42018-04-17 15:12:58 +0000431FORM_GetFocusedText(FPDF_FORMHANDLE hHandle,
432 FPDF_PAGE page,
433 void* buffer,
434 unsigned long buflen) {
435 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
436 if (!pPageView)
437 return 0;
438
439 return Utf16EncodeMaybeCopyAndReturnLength(pPageView->GetFocusedFormText(),
440 buffer, buflen);
441}
442
443FPDF_EXPORT unsigned long FPDF_CALLCONV
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400444FORM_GetSelectedText(FPDF_FORMHANDLE hHandle,
445 FPDF_PAGE page,
446 void* buffer,
447 unsigned long buflen) {
Diana Gagedce2d722017-06-20 11:17:11 -0700448 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
449 if (!pPageView)
450 return 0;
451
Lei Zhanga4c7ac42018-04-17 15:12:58 +0000452 return Utf16EncodeMaybeCopyAndReturnLength(pPageView->GetSelectedText(),
453 buffer, buflen);
Diana Gagedce2d722017-06-20 11:17:11 -0700454}
455
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400456FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle,
457 FPDF_PAGE page,
458 FPDF_WIDESTRING wsText) {
Diana Gage1c7f1422017-07-24 11:19:52 -0700459 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
460 if (!pPageView)
461 return;
Diana Gageab390972017-07-28 17:07:39 -0700462
Ryan Harrison875e98c2017-09-27 10:53:11 -0400463 size_t len = WideString::WStringLength(wsText);
Ryan Harrison275e2602017-09-18 14:23:18 -0400464 WideString wide_str_text = WideString::FromUTF16LE(wsText, len);
Diana Gageab390972017-07-28 17:07:39 -0700465
466 pPageView->ReplaceSelection(wide_str_text);
Diana Gage1c7f1422017-07-24 11:19:52 -0700467}
468
Lei Zhangee967722018-04-19 20:55:54 +0000469FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanUndo(FPDF_FORMHANDLE hHandle,
470 FPDF_PAGE page) {
471 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
472 if (!pPageView)
473 return false;
474 return pPageView->CanUndo();
475}
476
477FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanRedo(FPDF_FORMHANDLE hHandle,
478 FPDF_PAGE page) {
479 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
480 if (!pPageView)
481 return false;
482 return pPageView->CanRedo();
483}
484
485FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Undo(FPDF_FORMHANDLE hHandle,
486 FPDF_PAGE page) {
487 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
488 if (!pPageView)
489 return false;
490 return pPageView->Undo();
491}
492
493FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Redo(FPDF_FORMHANDLE hHandle,
494 FPDF_PAGE page) {
495 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
496 if (!pPageView)
497 return false;
498 return pPageView->Redo();
499}
500
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400501FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
502FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700503 CPDFSDK_FormFillEnvironment* pFormFillEnv =
504 HandleToCPDFSDKEnvironment(hHandle);
505 if (!pFormFillEnv)
tsepez4cf55152016-11-02 14:37:54 -0700506 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700507 return pFormFillEnv->KillFocusAnnot(0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700508}
509
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400510FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
511 FPDF_BITMAP bitmap,
512 FPDF_PAGE page,
513 int start_x,
514 int start_y,
515 int size_x,
516 int size_y,
517 int rotate,
518 int flags) {
Cary Clark399be5b2016-03-14 16:51:29 -0400519 FFLCommon(hHandle, bitmap, nullptr, page, start_x, start_y, size_x, size_y,
520 rotate, flags);
521}
522
523#ifdef _SKIA_SUPPORT_
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400524FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLRecord(FPDF_FORMHANDLE hHandle,
525 FPDF_RECORDER recorder,
526 FPDF_PAGE page,
527 int start_x,
528 int start_y,
529 int size_x,
530 int size_y,
531 int rotate,
532 int flags) {
Cary Clark399be5b2016-03-14 16:51:29 -0400533 FFLCommon(hHandle, nullptr, recorder, page, start_x, start_y, size_x, size_y,
534 rotate, flags);
535}
536#endif
537
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400538FPDF_EXPORT void FPDF_CALLCONV
539FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
540 int fieldType,
541 unsigned long color) {
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000542 CPDFSDK_InterForm* interForm = FormHandleToInterForm(hHandle);
543 if (!interForm)
544 return;
545
546 Optional<FormFieldType> cast_input = IntToFormFieldType(fieldType);
Ryan Harrison2056fac2018-01-16 16:06:45 +0000547 if (!cast_input)
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000548 return;
549
550 if (cast_input.value() == FormFieldType::kUnknown) {
551 interForm->SetAllHighlightColors(color);
552 } else {
553 interForm->SetHighlightColor(color, cast_input.value());
554 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700555}
556
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400557FPDF_EXPORT void FPDF_CALLCONV
558FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700559 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
560 pInterForm->SetHighlightAlpha(alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700561}
562
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400563FPDF_EXPORT void FPDF_CALLCONV
564FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700565 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000566 pInterForm->RemoveAllHighLights();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700567}
568
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400569FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page,
570 FPDF_FORMHANDLE hHandle) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700571 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
tsepez4cf55152016-11-02 14:37:54 -0700572 pPageView->SetValid(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700573}
574
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400575FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page,
576 FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700577 CPDFSDK_FormFillEnvironment* pFormFillEnv =
578 HandleToCPDFSDKEnvironment(hHandle);
579 if (!pFormFillEnv)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700580 return;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700581
Tom Sepez540c4362015-11-24 13:33:57 -0800582 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
583 if (!pPage)
584 return;
585
dsinclair7cbe68e2016-10-12 11:56:23 -0700586 CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700587 if (pPageView) {
tsepez4cf55152016-11-02 14:37:54 -0700588 pPageView->SetValid(false);
Tom Sepez50d12ad2015-11-24 09:50:51 -0800589 // RemovePageView() takes care of the delete for us.
dsinclair7cbe68e2016-10-12 11:56:23 -0700590 pFormFillEnv->RemovePageView(pPage);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700591 }
592}
593
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400594FPDF_EXPORT void FPDF_CALLCONV
595FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700596 CPDFSDK_FormFillEnvironment* pFormFillEnv =
597 HandleToCPDFSDKEnvironment(hHandle);
Tom Sepezf5ca90c2018-02-01 02:15:44 +0000598 if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent())
dsinclair7cbe68e2016-10-12 11:56:23 -0700599 pFormFillEnv->ProcJavascriptFun();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700600}
601
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400602FPDF_EXPORT void FPDF_CALLCONV
603FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
dsinclairf3fbe832016-10-11 13:08:04 -0700604 CPDFSDK_FormFillEnvironment* pFormFillEnv =
605 HandleToCPDFSDKEnvironment(hHandle);
Tom Sepezf5ca90c2018-02-01 02:15:44 +0000606 if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent())
dsinclair7cbe68e2016-10-12 11:56:23 -0700607 pFormFillEnv->ProcOpenAction();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700608}
609
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400610FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
611 int aaType) {
dsinclairf3fbe832016-10-11 13:08:04 -0700612 CPDFSDK_FormFillEnvironment* pFormFillEnv =
613 HandleToCPDFSDKEnvironment(hHandle);
614 if (!pFormFillEnv)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700615 return;
616
dsinclair7cbe68e2016-10-12 11:56:23 -0700617 CPDF_Document* pDoc = pFormFillEnv->GetPDFDocument();
Lei Zhang01581062017-08-30 14:19:26 -0700618 const CPDF_Dictionary* pDict = pDoc->GetRoot();
Lei Zhang1fed5a22017-06-01 11:52:22 -0700619 if (!pDict)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700620 return;
Tom Sepez468e5892015-10-13 15:49:36 -0700621
Lei Zhang1fed5a22017-06-01 11:52:22 -0700622 CPDF_AAction aa(pDict->GetDictFor("AA"));
623 auto type = static_cast<CPDF_AAction::AActionType>(aaType);
624 if (aa.ActionExist(type)) {
625 CPDF_Action action = aa.GetAction(type);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700626 CPDFSDK_ActionHandler* pActionHandler =
Lei Zhangcddc8ed2017-06-20 17:26:44 -0700627 HandleToCPDFSDKEnvironment(hHandle)->GetActionHandler();
Lei Zhang1fed5a22017-06-01 11:52:22 -0700628 pActionHandler->DoAction_Document(action, type, pFormFillEnv);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700629 }
630}
631
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400632FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
633 FPDF_FORMHANDLE hHandle,
634 int aaType) {
dsinclairf3fbe832016-10-11 13:08:04 -0700635 CPDFSDK_FormFillEnvironment* pFormFillEnv =
636 HandleToCPDFSDKEnvironment(hHandle);
637 if (!pFormFillEnv)
tonikitoo401d4f22016-08-10 11:37:45 -0700638 return;
639
Tom Sepez540c4362015-11-24 13:33:57 -0800640 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
641 CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
Tom Sepezde4791d2015-10-30 12:13:10 -0700642 if (!pPDFPage)
643 return;
tonikitoo401d4f22016-08-10 11:37:45 -0700644
dsinclair7cbe68e2016-10-12 11:56:23 -0700645 if (!pFormFillEnv->GetPageView(pPage, false))
tonikitoo401d4f22016-08-10 11:37:45 -0700646 return;
647
Lei Zhangcddc8ed2017-06-20 17:26:44 -0700648 CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHandler();
Tom Sepez4cb82ee2017-05-22 15:15:30 -0700649 CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict.Get();
dsinclair38fd8442016-09-15 10:15:32 -0700650 CPDF_AAction aa(pPageDict->GetDictFor("AA"));
Lei Zhang1fed5a22017-06-01 11:52:22 -0700651 CPDF_AAction::AActionType type = aaType == FPDFPAGE_AACTION_OPEN
652 ? CPDF_AAction::OpenPage
653 : CPDF_AAction::ClosePage;
654 if (aa.ActionExist(type)) {
655 CPDF_Action action = aa.GetAction(type);
656 pActionHandler->DoAction_Page(action, type, pFormFillEnv);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700657 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700658}