1 // Copyright 2016 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/cpdfsdk_widget.h"
8
9 #include "constants/access_permissions.h"
10 #include "constants/annotation_common.h"
11 #include "constants/appearance.h"
12 #include "constants/form_flags.h"
13 #include "core/fpdfapi/parser/cpdf_array.h"
14 #include "core/fpdfapi/parser/cpdf_dictionary.h"
15 #include "core/fpdfapi/parser/cpdf_document.h"
16 #include "core/fpdfapi/parser/cpdf_reference.h"
17 #include "core/fpdfapi/parser/cpdf_stream.h"
18 #include "core/fpdfapi/parser/cpdf_string.h"
19 #include "core/fpdfdoc/cpdf_bafontmap.h"
20 #include "core/fpdfdoc/cpdf_defaultappearance.h"
21 #include "core/fpdfdoc/cpdf_formcontrol.h"
22 #include "core/fpdfdoc/cpdf_formfield.h"
23 #include "core/fpdfdoc/cpdf_iconfit.h"
24 #include "core/fpdfdoc/cpdf_interactiveform.h"
25 #include "core/fxge/cfx_fillrenderoptions.h"
26 #include "core/fxge/cfx_graphstatedata.h"
27 #include "core/fxge/cfx_path.h"
28 #include "core/fxge/cfx_renderdevice.h"
29 #include "fpdfsdk/cpdfsdk_appstream.h"
30 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
31 #include "fpdfsdk/cpdfsdk_interactiveform.h"
32 #include "fpdfsdk/cpdfsdk_pageview.h"
33 #include "fpdfsdk/formfiller/cffl_fieldaction.h"
34 #include "fpdfsdk/pwl/cpwl_edit.h"
35 #include "third_party/base/check.h"
36 #include "third_party/base/notreached.h"
37
38 #ifdef PDF_ENABLE_XFA
39 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
40 #include "xfa/fxfa/cxfa_eventparam.h"
41 #include "xfa/fxfa/cxfa_ffdocview.h"
42 #include "xfa/fxfa/cxfa_ffwidget.h"
43 #include "xfa/fxfa/cxfa_ffwidgethandler.h"
44 #include "xfa/fxfa/parser/cxfa_node.h"
45 #endif // PDF_ENABLE_XFA
46
CPDFSDK_Widget(CPDF_Annot * pAnnot,CPDFSDK_PageView * pPageView,CPDFSDK_InteractiveForm * pInteractiveForm)47 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot,
48 CPDFSDK_PageView* pPageView,
49 CPDFSDK_InteractiveForm* pInteractiveForm)
50 : CPDFSDK_BAAnnot(pAnnot, pPageView),
51 m_pInteractiveForm(pInteractiveForm) {}
52
~CPDFSDK_Widget()53 CPDFSDK_Widget::~CPDFSDK_Widget() {
54 GetInteractiveFormFiller()->OnDelete(this);
55 m_pInteractiveForm->RemoveMap(GetFormControl());
56 }
57
58 #ifdef PDF_ENABLE_XFA
GetMixXFAWidget() const59 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
60 CPDF_Document::Extension* pContext =
61 GetPageView()->GetFormFillEnv()->GetDocExtension();
62 if (!pContext || !pContext->ContainsExtensionForegroundForm())
63 return nullptr;
64
65 CXFA_FFDocView* pDocView =
66 static_cast<CPDFXFA_Context*>(pContext)->GetXFADocView();
67 if (!pDocView)
68 return nullptr;
69
70 WideString sName;
71 if (GetFieldType() == FormFieldType::kRadioButton) {
72 sName = GetAnnotName();
73 if (sName.IsEmpty())
74 sName = GetName();
75 } else {
76 sName = GetName();
77 }
78
79 if (sName.IsEmpty())
80 return nullptr;
81
82 return pDocView->GetWidgetByName(sName, nullptr);
83 }
84
GetGroupMixXFAWidget() const85 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() const {
86 CPDF_Document::Extension* pContext =
87 GetPageView()->GetFormFillEnv()->GetDocExtension();
88 if (!pContext || !pContext->ContainsExtensionForegroundForm())
89 return nullptr;
90
91 CXFA_FFDocView* pDocView =
92 static_cast<CPDFXFA_Context*>(pContext)->GetXFADocView();
93 if (!pDocView)
94 return nullptr;
95
96 WideString sName = GetName();
97 return !sName.IsEmpty() ? pDocView->GetWidgetByName(sName, nullptr) : nullptr;
98 }
99
GetXFAWidgetHandler() const100 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const {
101 CPDF_Document::Extension* pContext =
102 GetPageView()->GetFormFillEnv()->GetDocExtension();
103 if (!pContext || !pContext->ContainsExtensionForegroundForm())
104 return nullptr;
105
106 CXFA_FFDocView* pDocView =
107 static_cast<CPDFXFA_Context*>(pContext)->GetXFADocView();
108 return pDocView ? pDocView->GetWidgetHandler() : nullptr;
109 }
110
GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT)111 static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) {
112 XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown;
113
114 switch (eXFAAAT) {
115 case PDFSDK_XFA_Click:
116 eEventType = XFA_EVENT_Click;
117 break;
118 case PDFSDK_XFA_Full:
119 eEventType = XFA_EVENT_Full;
120 break;
121 case PDFSDK_XFA_PreOpen:
122 eEventType = XFA_EVENT_PreOpen;
123 break;
124 case PDFSDK_XFA_PostOpen:
125 eEventType = XFA_EVENT_PostOpen;
126 break;
127 }
128
129 return eEventType;
130 }
131
GetXFAEventType(CPDF_AAction::AActionType eAAT,bool bWillCommit)132 static XFA_EVENTTYPE GetXFAEventType(CPDF_AAction::AActionType eAAT,
133 bool bWillCommit) {
134 XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown;
135
136 switch (eAAT) {
137 case CPDF_AAction::kCursorEnter:
138 eEventType = XFA_EVENT_MouseEnter;
139 break;
140 case CPDF_AAction::kCursorExit:
141 eEventType = XFA_EVENT_MouseExit;
142 break;
143 case CPDF_AAction::kButtonDown:
144 eEventType = XFA_EVENT_MouseDown;
145 break;
146 case CPDF_AAction::kButtonUp:
147 eEventType = XFA_EVENT_MouseUp;
148 break;
149 case CPDF_AAction::kGetFocus:
150 eEventType = XFA_EVENT_Enter;
151 break;
152 case CPDF_AAction::kLoseFocus:
153 eEventType = XFA_EVENT_Exit;
154 break;
155 case CPDF_AAction::kPageOpen:
156 case CPDF_AAction::kPageClose:
157 case CPDF_AAction::kPageVisible:
158 case CPDF_AAction::kPageInvisible:
159 break;
160 case CPDF_AAction::kKeyStroke:
161 if (!bWillCommit)
162 eEventType = XFA_EVENT_Change;
163 break;
164 case CPDF_AAction::kValidate:
165 eEventType = XFA_EVENT_Validate;
166 break;
167 case CPDF_AAction::kOpenPage:
168 case CPDF_AAction::kClosePage:
169 case CPDF_AAction::kFormat:
170 case CPDF_AAction::kCalculate:
171 case CPDF_AAction::kCloseDocument:
172 case CPDF_AAction::kSaveDocument:
173 case CPDF_AAction::kDocumentSaved:
174 case CPDF_AAction::kPrintDocument:
175 case CPDF_AAction::kDocumentPrinted:
176 break;
177 case CPDF_AAction::kDocumentOpen:
178 case CPDF_AAction::kNumberOfActions:
179 NOTREACHED_NORETURN();
180 break;
181 }
182
183 return eEventType;
184 }
185
HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) const186 bool CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) const {
187 CXFA_FFWidget* pWidget = GetMixXFAWidget();
188 if (!pWidget)
189 return false;
190
191 CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler();
192 if (!pXFAWidgetHandler)
193 return false;
194
195 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT);
196 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) &&
197 GetFieldType() == FormFieldType::kRadioButton) {
198 CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget();
199 if (hGroupWidget &&
200 hGroupWidget->HasEventUnderHandler(eEventType, pXFAWidgetHandler)) {
201 return true;
202 }
203 }
204
205 return pWidget->HasEventUnderHandler(eEventType, pXFAWidgetHandler);
206 }
207
OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT,CFFL_FieldAction * data,const CPDFSDK_PageView * pPageView)208 bool CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT,
209 CFFL_FieldAction* data,
210 const CPDFSDK_PageView* pPageView) {
211 auto* pContext = static_cast<CPDFXFA_Context*>(
212 GetPageView()->GetFormFillEnv()->GetDocExtension());
213 if (!pContext)
214 return false;
215
216 CXFA_FFWidget* pWidget = GetMixXFAWidget();
217 if (!pWidget)
218 return false;
219
220 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT);
221 if (eEventType == XFA_EVENT_Unknown)
222 return false;
223
224 CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler();
225 if (!pXFAWidgetHandler)
226 return false;
227
228 CXFA_EventParam param;
229 param.m_eType = eEventType;
230 param.m_wsChange = data->sChange;
231 param.m_iCommitKey = 0;
232 param.m_bShift = data->bShift;
233 param.m_iSelStart = data->nSelStart;
234 param.m_iSelEnd = data->nSelEnd;
235 param.m_wsFullText = data->sValue;
236 param.m_bKeyDown = data->bKeyDown;
237 param.m_bModifier = data->bModifier;
238 param.m_wsPrevText = data->sValue;
239 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) &&
240 GetFieldType() == FormFieldType::kRadioButton) {
241 CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget();
242 if (hGroupWidget &&
243 !hGroupWidget->ProcessEventUnderHandler(¶m, pXFAWidgetHandler)) {
244 return false;
245 }
246 }
247
248 bool ret = pWidget->ProcessEventUnderHandler(¶m, pXFAWidgetHandler);
249 CXFA_FFDocView* pDocView = pContext->GetXFADocView();
250 if (pDocView)
251 pDocView->UpdateDocView();
252
253 return ret;
254 }
255
Synchronize(bool bSynchronizeElse)256 void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) {
257 CXFA_FFWidget* hWidget = GetMixXFAWidget();
258 if (!hWidget)
259 return;
260
261 CXFA_Node* node = hWidget->GetNode();
262 if (!node->IsWidgetReady())
263 return;
264
265 CPDF_FormField* pFormField = GetFormField();
266 switch (GetFieldType()) {
267 case FormFieldType::kCheckBox:
268 case FormFieldType::kRadioButton: {
269 CPDF_FormControl* pFormCtrl = GetFormControl();
270 XFA_CheckState eCheckState =
271 pFormCtrl->IsChecked() ? XFA_CheckState::kOn : XFA_CheckState::kOff;
272 node->SetCheckState(eCheckState);
273 break;
274 }
275 case FormFieldType::kTextField:
276 node->SetValue(XFA_ValuePicture::kEdit, pFormField->GetValue());
277 break;
278 case FormFieldType::kComboBox:
279 case FormFieldType::kListBox: {
280 node->ClearAllSelections();
281 for (int i = 0; i < pFormField->CountSelectedItems(); ++i) {
282 int nIndex = pFormField->GetSelectedIndex(i);
283 if (nIndex > -1 &&
284 static_cast<size_t>(nIndex) < node->CountChoiceListItems(false)) {
285 node->SetItemState(nIndex, true, false, false);
286 }
287 }
288 if (GetFieldType() == FormFieldType::kComboBox)
289 node->SetValue(XFA_ValuePicture::kEdit, pFormField->GetValue());
290 break;
291 }
292 default:
293 break;
294 }
295
296 if (bSynchronizeElse) {
297 auto* context = static_cast<CPDFXFA_Context*>(
298 GetPageView()->GetFormFillEnv()->GetDocExtension());
299 context->GetXFADocView()->ProcessValueChanged(node);
300 }
301 }
302
HandleXFAAAction(CPDF_AAction::AActionType type,CFFL_FieldAction * data,CPDFSDK_FormFillEnvironment * pFormFillEnv)303 bool CPDFSDK_Widget::HandleXFAAAction(
304 CPDF_AAction::AActionType type,
305 CFFL_FieldAction* data,
306 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
307 auto* pContext =
308 static_cast<CPDFXFA_Context*>(pFormFillEnv->GetDocExtension());
309 if (!pContext)
310 return false;
311
312 CXFA_FFWidget* hWidget = GetMixXFAWidget();
313 if (!hWidget)
314 return false;
315
316 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data->bWillCommit);
317 if (eEventType == XFA_EVENT_Unknown)
318 return false;
319
320 CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler();
321 if (!pXFAWidgetHandler)
322 return false;
323
324 CXFA_EventParam param;
325 param.m_eType = eEventType;
326 param.m_wsChange = data->sChange;
327 param.m_iCommitKey = 0;
328 param.m_bShift = data->bShift;
329 param.m_iSelStart = data->nSelStart;
330 param.m_iSelEnd = data->nSelEnd;
331 param.m_wsFullText = data->sValue;
332 param.m_bKeyDown = data->bKeyDown;
333 param.m_bModifier = data->bModifier;
334 param.m_wsPrevText = data->sValue;
335 bool ret = hWidget->ProcessEventUnderHandler(¶m, pXFAWidgetHandler);
336 CXFA_FFDocView* pDocView = pContext->GetXFADocView();
337 if (pDocView)
338 pDocView->UpdateDocView();
339
340 return ret;
341 }
342 #endif // PDF_ENABLE_XFA
343
IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) const344 bool CPDFSDK_Widget::IsWidgetAppearanceValid(
345 CPDF_Annot::AppearanceMode mode) const {
346 RetainPtr<const CPDF_Dictionary> pAP =
347 GetAnnotDict()->GetDictFor(pdfium::annotation::kAP);
348 if (!pAP)
349 return false;
350
351 // Choose the right sub-ap
352 const char* ap_entry = "N";
353 if (mode == CPDF_Annot::AppearanceMode::kDown)
354 ap_entry = "D";
355 else if (mode == CPDF_Annot::AppearanceMode::kRollover)
356 ap_entry = "R";
357 if (!pAP->KeyExist(ap_entry))
358 ap_entry = "N";
359
360 // Get the AP stream or subdirectory
361 RetainPtr<const CPDF_Object> pSub = pAP->GetDirectObjectFor(ap_entry);
362 if (!pSub)
363 return false;
364
365 FormFieldType fieldType = GetFieldType();
366 switch (fieldType) {
367 case FormFieldType::kPushButton:
368 case FormFieldType::kComboBox:
369 case FormFieldType::kListBox:
370 case FormFieldType::kTextField:
371 case FormFieldType::kSignature:
372 return pSub->IsStream();
373 case FormFieldType::kCheckBox:
374 case FormFieldType::kRadioButton:
375 if (const CPDF_Dictionary* pSubDict = pSub->AsDictionary()) {
376 return !!pSubDict->GetStreamFor(GetAppState());
377 }
378 return false;
379 default:
380 return true;
381 }
382 }
383
IsPushHighlighted() const384 bool CPDFSDK_Widget::IsPushHighlighted() const {
385 return GetFormControl()->GetHighlightingMode() == CPDF_FormControl::kPush;
386 }
387
GetFieldType() const388 FormFieldType CPDFSDK_Widget::GetFieldType() const {
389 CPDF_FormField* pField = GetFormField();
390 return pField ? pField->GetFieldType() : FormFieldType::kUnknown;
391 }
392
SetRect(const CFX_FloatRect & rect)393 void CPDFSDK_Widget::SetRect(const CFX_FloatRect& rect) {
394 DCHECK(rect.right - rect.left >= 1.0f);
395 DCHECK(rect.top - rect.bottom >= 1.0f);
396 GetMutableAnnotDict()->SetRectFor(pdfium::annotation::kRect, rect);
397 }
398
IsAppearanceValid()399 bool CPDFSDK_Widget::IsAppearanceValid() {
400 #ifdef PDF_ENABLE_XFA
401 CPDF_Document::Extension* pContext =
402 GetPageView()->GetFormFillEnv()->GetDocExtension();
403 if (pContext && pContext->ContainsExtensionFullForm())
404 return true;
405 #endif // PDF_ENABLE_XFA
406 return CPDFSDK_BAAnnot::IsAppearanceValid();
407 }
408
GetLayoutOrder() const409 int CPDFSDK_Widget::GetLayoutOrder() const {
410 return 2;
411 }
412
GetFieldFlags() const413 int CPDFSDK_Widget::GetFieldFlags() const {
414 return GetFormField()->GetFieldFlags();
415 }
416
IsSignatureWidget() const417 bool CPDFSDK_Widget::IsSignatureWidget() const {
418 return GetFieldType() == FormFieldType::kSignature;
419 }
420
GetFormField() const421 CPDF_FormField* CPDFSDK_Widget::GetFormField() const {
422 CPDF_FormControl* pControl = GetFormControl();
423 return pControl ? pControl->GetField() : nullptr;
424 }
425
GetFormControl() const426 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const {
427 CPDF_InteractiveForm* pPDFInteractiveForm =
428 m_pInteractiveForm->GetInteractiveForm();
429 return pPDFInteractiveForm->GetControlByDict(GetAnnotDict());
430 }
431
GetRotate() const432 int CPDFSDK_Widget::GetRotate() const {
433 CPDF_FormControl* pCtrl = GetFormControl();
434 return pCtrl->GetRotation() % 360;
435 }
436
437 #ifdef PDF_ENABLE_XFA
GetName() const438 WideString CPDFSDK_Widget::GetName() const {
439 return GetFormField()->GetFullName();
440 }
441 #endif // PDF_ENABLE_XFA
442
GetFillColor() const443 absl::optional<FX_COLORREF> CPDFSDK_Widget::GetFillColor() const {
444 CFX_Color::TypeAndARGB type_argb_pair =
445 GetFormControl()->GetColorARGB(pdfium::appearance::kBG);
446
447 if (type_argb_pair.color_type == CFX_Color::Type::kTransparent)
448 return absl::nullopt;
449
450 return ArgbToColorRef(type_argb_pair.argb);
451 }
452
GetBorderColor() const453 absl::optional<FX_COLORREF> CPDFSDK_Widget::GetBorderColor() const {
454 CFX_Color::TypeAndARGB type_argb_pair =
455 GetFormControl()->GetColorARGB(pdfium::appearance::kBC);
456 if (type_argb_pair.color_type == CFX_Color::Type::kTransparent)
457 return absl::nullopt;
458
459 return ArgbToColorRef(type_argb_pair.argb);
460 }
461
GetTextColor() const462 absl::optional<FX_COLORREF> CPDFSDK_Widget::GetTextColor() const {
463 CPDF_DefaultAppearance da = GetFormControl()->GetDefaultAppearance();
464 absl::optional<CFX_Color::TypeAndARGB> maybe_type_argb_pair =
465 da.GetColorARGB();
466
467 if (!maybe_type_argb_pair.has_value())
468 return absl::nullopt;
469
470 if (maybe_type_argb_pair.value().color_type == CFX_Color::Type::kTransparent)
471 return absl::nullopt;
472
473 return ArgbToColorRef(maybe_type_argb_pair.value().argb);
474 }
475
GetFontSize() const476 float CPDFSDK_Widget::GetFontSize() const {
477 CPDF_FormControl* pFormCtrl = GetFormControl();
478 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance();
479 float fFontSize;
480 pDa.GetFont(&fFontSize);
481 return fFontSize;
482 }
483
GetSelectedIndex(int nIndex) const484 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const {
485 #ifdef PDF_ENABLE_XFA
486 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) {
487 CXFA_Node* node = hWidget->GetNode();
488 if (node->IsWidgetReady()) {
489 if (nIndex < node->CountSelectedItems())
490 return node->GetSelectedItem(nIndex);
491 }
492 }
493 #endif // PDF_ENABLE_XFA
494 CPDF_FormField* pFormField = GetFormField();
495 return pFormField->GetSelectedIndex(nIndex);
496 }
497
GetValue() const498 WideString CPDFSDK_Widget::GetValue() const {
499 #ifdef PDF_ENABLE_XFA
500 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) {
501 CXFA_Node* node = hWidget->GetNode();
502 if (node->IsWidgetReady())
503 return node->GetValue(XFA_ValuePicture::kDisplay);
504 }
505 #endif // PDF_ENABLE_XFA
506 CPDF_FormField* pFormField = GetFormField();
507 return pFormField->GetValue();
508 }
509
GetExportValue() const510 WideString CPDFSDK_Widget::GetExportValue() const {
511 CPDF_FormControl* pFormCtrl = GetFormControl();
512 return pFormCtrl->GetExportValue();
513 }
514
GetOptionLabel(int nIndex) const515 WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const {
516 CPDF_FormField* pFormField = GetFormField();
517 return pFormField->GetOptionLabel(nIndex);
518 }
519
GetSelectExportText(int nIndex) const520 WideString CPDFSDK_Widget::GetSelectExportText(int nIndex) const {
521 if (nIndex < 0)
522 return WideString();
523
524 CPDF_FormField* pFormField = GetFormField();
525 if (!pFormField)
526 return WideString();
527
528 WideString swRet = pFormField->GetOptionValue(nIndex);
529 if (!swRet.IsEmpty())
530 return swRet;
531
532 return pFormField->GetOptionLabel(nIndex);
533 }
534
CountOptions() const535 int CPDFSDK_Widget::CountOptions() const {
536 CPDF_FormField* pFormField = GetFormField();
537 return pFormField->CountOptions();
538 }
539
IsOptionSelected(int nIndex) const540 bool CPDFSDK_Widget::IsOptionSelected(int nIndex) const {
541 #ifdef PDF_ENABLE_XFA
542 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) {
543 CXFA_Node* node = hWidget->GetNode();
544 if (node->IsWidgetReady()) {
545 if (nIndex > -1 &&
546 static_cast<size_t>(nIndex) < node->CountChoiceListItems(false)) {
547 return node->GetItemState(nIndex);
548 }
549 return false;
550 }
551 }
552 #endif // PDF_ENABLE_XFA
553 CPDF_FormField* pFormField = GetFormField();
554 return pFormField->IsItemSelected(nIndex);
555 }
556
GetTopVisibleIndex() const557 int CPDFSDK_Widget::GetTopVisibleIndex() const {
558 CPDF_FormField* pFormField = GetFormField();
559 return pFormField->GetTopVisibleIndex();
560 }
561
IsChecked() const562 bool CPDFSDK_Widget::IsChecked() const {
563 #ifdef PDF_ENABLE_XFA
564 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) {
565 CXFA_Node* node = hWidget->GetNode();
566 if (node->IsWidgetReady())
567 return node->GetCheckState() == XFA_CheckState::kOn;
568 }
569 #endif // PDF_ENABLE_XFA
570 CPDF_FormControl* pFormCtrl = GetFormControl();
571 return pFormCtrl->IsChecked();
572 }
573
GetAlignment() const574 int CPDFSDK_Widget::GetAlignment() const {
575 CPDF_FormControl* pFormCtrl = GetFormControl();
576 return pFormCtrl->GetControlAlignment();
577 }
578
GetMaxLen() const579 int CPDFSDK_Widget::GetMaxLen() const {
580 CPDF_FormField* pFormField = GetFormField();
581 return pFormField->GetMaxLen();
582 }
583
SetCheck(bool bChecked)584 void CPDFSDK_Widget::SetCheck(bool bChecked) {
585 CPDF_FormControl* pFormCtrl = GetFormControl();
586 CPDF_FormField* pFormField = pFormCtrl->GetField();
587 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked,
588 NotificationOption::kDoNotNotify);
589 #ifdef PDF_ENABLE_XFA
590 if (!IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode::kNormal))
591 ResetXFAAppearance(CPDFSDK_Widget::kValueChanged);
592 Synchronize(true);
593 #endif // PDF_ENABLE_XFA
594 }
595
SetValue(const WideString & sValue)596 void CPDFSDK_Widget::SetValue(const WideString& sValue) {
597 CPDF_FormField* pFormField = GetFormField();
598 pFormField->SetValue(sValue, NotificationOption::kDoNotNotify);
599 #ifdef PDF_ENABLE_XFA
600 Synchronize(true);
601 #endif // PDF_ENABLE_XFA
602 }
603
SetOptionSelection(int index)604 void CPDFSDK_Widget::SetOptionSelection(int index) {
605 CPDF_FormField* pFormField = GetFormField();
606 pFormField->SetItemSelection(index, NotificationOption::kDoNotNotify);
607 #ifdef PDF_ENABLE_XFA
608 Synchronize(true);
609 #endif // PDF_ENABLE_XFA
610 }
611
ClearSelection()612 void CPDFSDK_Widget::ClearSelection() {
613 CPDF_FormField* pFormField = GetFormField();
614 pFormField->ClearSelection(NotificationOption::kDoNotNotify);
615 #ifdef PDF_ENABLE_XFA
616 Synchronize(true);
617 #endif // PDF_ENABLE_XFA
618 }
619
SetTopVisibleIndex(int index)620 void CPDFSDK_Widget::SetTopVisibleIndex(int index) {}
621
SetAppModified()622 void CPDFSDK_Widget::SetAppModified() {
623 m_bAppModified = true;
624 }
625
ClearAppModified()626 void CPDFSDK_Widget::ClearAppModified() {
627 m_bAppModified = false;
628 }
629
IsAppModified() const630 bool CPDFSDK_Widget::IsAppModified() const {
631 return m_bAppModified;
632 }
633
634 #ifdef PDF_ENABLE_XFA
ResetXFAAppearance(ValueChanged bValueChanged)635 void CPDFSDK_Widget::ResetXFAAppearance(ValueChanged bValueChanged) {
636 switch (GetFieldType()) {
637 case FormFieldType::kTextField:
638 case FormFieldType::kComboBox: {
639 ResetAppearance(OnFormat(), kValueChanged);
640 break;
641 }
642 default:
643 ResetAppearance(absl::nullopt, kValueUnchanged);
644 break;
645 }
646 }
647 #endif // PDF_ENABLE_XFA
648
ResetAppearance(absl::optional<WideString> sValue,ValueChanged bValueChanged)649 void CPDFSDK_Widget::ResetAppearance(absl::optional<WideString> sValue,
650 ValueChanged bValueChanged) {
651 SetAppModified();
652
653 m_nAppearanceAge++;
654 if (bValueChanged == kValueChanged)
655 m_nValueAge++;
656
657 CPDFSDK_AppStream appStream(this, GetAPDict().Get());
658 switch (GetFieldType()) {
659 case FormFieldType::kPushButton:
660 appStream.SetAsPushButton();
661 break;
662 case FormFieldType::kCheckBox:
663 appStream.SetAsCheckBox();
664 break;
665 case FormFieldType::kRadioButton:
666 appStream.SetAsRadioButton();
667 break;
668 case FormFieldType::kComboBox:
669 appStream.SetAsComboBox(sValue);
670 break;
671 case FormFieldType::kListBox:
672 appStream.SetAsListBox();
673 break;
674 case FormFieldType::kTextField:
675 appStream.SetAsTextField(sValue);
676 break;
677 default:
678 break;
679 }
680
681 ClearCachedAnnotAP();
682 }
683
OnFormat()684 absl::optional<WideString> CPDFSDK_Widget::OnFormat() {
685 CPDF_FormField* pFormField = GetFormField();
686 DCHECK(pFormField);
687 return m_pInteractiveForm->OnFormat(pFormField);
688 }
689
ResetFieldAppearance()690 void CPDFSDK_Widget::ResetFieldAppearance() {
691 CPDF_FormField* pFormField = GetFormField();
692 DCHECK(pFormField);
693 m_pInteractiveForm->ResetFieldAppearance(pFormField, absl::nullopt);
694 }
695
OnDraw(CFX_RenderDevice * pDevice,const CFX_Matrix & mtUser2Device,bool bDrawAnnots)696 void CPDFSDK_Widget::OnDraw(CFX_RenderDevice* pDevice,
697 const CFX_Matrix& mtUser2Device,
698 bool bDrawAnnots) {
699 if (IsSignatureWidget()) {
700 DrawAppearance(pDevice, mtUser2Device, CPDF_Annot::AppearanceMode::kNormal);
701 return;
702 }
703
704 GetInteractiveFormFiller()->OnDraw(GetPageView(), this, pDevice,
705 mtUser2Device);
706 }
707
DoHitTest(const CFX_PointF & point)708 bool CPDFSDK_Widget::DoHitTest(const CFX_PointF& point) {
709 if (IsSignatureWidget() || !IsVisible())
710 return false;
711
712 if (GetFieldFlags() & pdfium::form_flags::kReadOnly)
713 return false;
714
715 bool do_hit_test = GetFieldType() == FormFieldType::kPushButton;
716 if (!do_hit_test) {
717 uint32_t perms = GetPDFPage()->GetDocument()->GetUserPermissions();
718 do_hit_test = (perms & pdfium::access_permissions::kFillForm) ||
719 (perms & pdfium::access_permissions::kModifyAnnotation);
720 }
721 return do_hit_test && GetViewBBox().Contains(point);
722 }
723
GetViewBBox()724 CFX_FloatRect CPDFSDK_Widget::GetViewBBox() {
725 if (IsSignatureWidget())
726 return CFX_FloatRect();
727
728 auto* form_filler = GetInteractiveFormFiller();
729 return CFX_FloatRect(form_filler->GetViewBBox(GetPageView(), this));
730 }
731
OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags)732 void CPDFSDK_Widget::OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags) {
733 if (IsSignatureWidget())
734 return;
735
736 ObservedPtr<CPDFSDK_Widget> observer(this);
737 GetInteractiveFormFiller()->OnMouseEnter(GetPageView(), observer, nFlags);
738 }
739
OnMouseExit(Mask<FWL_EVENTFLAG> nFlags)740 void CPDFSDK_Widget::OnMouseExit(Mask<FWL_EVENTFLAG> nFlags) {
741 if (IsSignatureWidget())
742 return;
743
744 ObservedPtr<CPDFSDK_Widget> observer(this);
745 GetInteractiveFormFiller()->OnMouseExit(GetPageView(), observer, nFlags);
746 }
747
OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)748 bool CPDFSDK_Widget::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,
749 const CFX_PointF& point) {
750 if (IsSignatureWidget())
751 return false;
752
753 ObservedPtr<CPDFSDK_Widget> observer(this);
754 return GetInteractiveFormFiller()->OnLButtonDown(GetPageView(), observer,
755 nFlags, point);
756 }
757
OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)758 bool CPDFSDK_Widget::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,
759 const CFX_PointF& point) {
760 if (IsSignatureWidget())
761 return false;
762
763 ObservedPtr<CPDFSDK_Widget> observer(this);
764 return GetInteractiveFormFiller()->OnLButtonUp(GetPageView(), observer,
765 nFlags, point);
766 }
767
OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)768 bool CPDFSDK_Widget::OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,
769 const CFX_PointF& point) {
770 if (IsSignatureWidget())
771 return false;
772
773 ObservedPtr<CPDFSDK_Widget> observer(this);
774 return GetInteractiveFormFiller()->OnLButtonDblClk(GetPageView(), observer,
775 nFlags, point);
776 }
777
OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)778 bool CPDFSDK_Widget::OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,
779 const CFX_PointF& point) {
780 if (IsSignatureWidget())
781 return false;
782
783 ObservedPtr<CPDFSDK_Widget> observer(this);
784 return GetInteractiveFormFiller()->OnMouseMove(GetPageView(), observer,
785 nFlags, point);
786 }
787
OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point,const CFX_Vector & delta)788 bool CPDFSDK_Widget::OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
789 const CFX_PointF& point,
790 const CFX_Vector& delta) {
791 if (IsSignatureWidget())
792 return false;
793
794 ObservedPtr<CPDFSDK_Widget> observer(this);
795 return GetInteractiveFormFiller()->OnMouseWheel(GetPageView(), observer,
796 nFlags, point, delta);
797 }
798
OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)799 bool CPDFSDK_Widget::OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,
800 const CFX_PointF& point) {
801 if (IsSignatureWidget())
802 return false;
803
804 ObservedPtr<CPDFSDK_Widget> observer(this);
805 return GetInteractiveFormFiller()->OnRButtonDown(GetPageView(), observer,
806 nFlags, point);
807 }
808
OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)809 bool CPDFSDK_Widget::OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,
810 const CFX_PointF& point) {
811 if (IsSignatureWidget())
812 return false;
813
814 ObservedPtr<CPDFSDK_Widget> observer(this);
815 return GetInteractiveFormFiller()->OnRButtonUp(GetPageView(), observer,
816 nFlags, point);
817 }
818
OnChar(uint32_t nChar,Mask<FWL_EVENTFLAG> nFlags)819 bool CPDFSDK_Widget::OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags) {
820 return !IsSignatureWidget() &&
821 GetInteractiveFormFiller()->OnChar(this, nChar, nFlags);
822 }
823
OnKeyDown(FWL_VKEYCODE nKeyCode,Mask<FWL_EVENTFLAG> nFlags)824 bool CPDFSDK_Widget::OnKeyDown(FWL_VKEYCODE nKeyCode,
825 Mask<FWL_EVENTFLAG> nFlags) {
826 return !IsSignatureWidget() &&
827 GetInteractiveFormFiller()->OnKeyDown(this, nKeyCode, nFlags);
828 }
829
OnSetFocus(Mask<FWL_EVENTFLAG> nFlags)830 bool CPDFSDK_Widget::OnSetFocus(Mask<FWL_EVENTFLAG> nFlags) {
831 if (!IsFocusableAnnot(GetPDFAnnot()->GetSubtype()))
832 return false;
833
834 if (IsSignatureWidget())
835 return true;
836
837 ObservedPtr<CPDFSDK_Widget> observer(this);
838 return GetInteractiveFormFiller()->OnSetFocus(observer, nFlags);
839 }
840
OnKillFocus(Mask<FWL_EVENTFLAG> nFlags)841 bool CPDFSDK_Widget::OnKillFocus(Mask<FWL_EVENTFLAG> nFlags) {
842 if (!IsFocusableAnnot(GetPDFAnnot()->GetSubtype()))
843 return false;
844
845 if (IsSignatureWidget())
846 return true;
847
848 ObservedPtr<CPDFSDK_Widget> observer(this);
849 return GetInteractiveFormFiller()->OnKillFocus(observer, nFlags);
850 }
851
CanUndo()852 bool CPDFSDK_Widget::CanUndo() {
853 return !IsSignatureWidget() && GetInteractiveFormFiller()->CanUndo(this);
854 }
855
CanRedo()856 bool CPDFSDK_Widget::CanRedo() {
857 return !IsSignatureWidget() && GetInteractiveFormFiller()->CanRedo(this);
858 }
859
Undo()860 bool CPDFSDK_Widget::Undo() {
861 return !IsSignatureWidget() && GetInteractiveFormFiller()->Undo(this);
862 }
863
Redo()864 bool CPDFSDK_Widget::Redo() {
865 return !IsSignatureWidget() && GetInteractiveFormFiller()->Redo(this);
866 }
867
GetText()868 WideString CPDFSDK_Widget::GetText() {
869 if (IsSignatureWidget())
870 return WideString();
871 return GetInteractiveFormFiller()->GetText(this);
872 }
873
GetSelectedText()874 WideString CPDFSDK_Widget::GetSelectedText() {
875 if (IsSignatureWidget())
876 return WideString();
877 return GetInteractiveFormFiller()->GetSelectedText(this);
878 }
879
ReplaceAndKeepSelection(const WideString & text)880 void CPDFSDK_Widget::ReplaceAndKeepSelection(const WideString& text) {
881 if (IsSignatureWidget())
882 return;
883
884 GetInteractiveFormFiller()->ReplaceAndKeepSelection(this, text);
885 }
886
ReplaceSelection(const WideString & text)887 void CPDFSDK_Widget::ReplaceSelection(const WideString& text) {
888 if (IsSignatureWidget())
889 return;
890
891 GetInteractiveFormFiller()->ReplaceSelection(this, text);
892 }
893
SelectAllText()894 bool CPDFSDK_Widget::SelectAllText() {
895 return !IsSignatureWidget() &&
896 GetInteractiveFormFiller()->SelectAllText(this);
897 }
898
SetIndexSelected(int index,bool selected)899 bool CPDFSDK_Widget::SetIndexSelected(int index, bool selected) {
900 ObservedPtr<CPDFSDK_Widget> observer(this);
901 return !IsSignatureWidget() && GetInteractiveFormFiller()->SetIndexSelected(
902 observer, index, selected);
903 }
904
IsIndexSelected(int index)905 bool CPDFSDK_Widget::IsIndexSelected(int index) {
906 ObservedPtr<CPDFSDK_Widget> observer(this);
907 return !IsSignatureWidget() &&
908 GetInteractiveFormFiller()->IsIndexSelected(observer, index);
909 }
910
DrawAppearance(CFX_RenderDevice * pDevice,const CFX_Matrix & mtUser2Device,CPDF_Annot::AppearanceMode mode)911 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice,
912 const CFX_Matrix& mtUser2Device,
913 CPDF_Annot::AppearanceMode mode) {
914 FormFieldType fieldType = GetFieldType();
915
916 if ((fieldType == FormFieldType::kCheckBox ||
917 fieldType == FormFieldType::kRadioButton) &&
918 mode == CPDF_Annot::AppearanceMode::kNormal &&
919 !IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode::kNormal)) {
920 CFX_GraphStateData gsd;
921 gsd.m_LineWidth = 0.0f;
922
923 CFX_Path path;
924 path.AppendFloatRect(GetRect());
925 pDevice->DrawPath(path, &mtUser2Device, &gsd, 0, 0xFFAAAAAA,
926 CFX_FillRenderOptions::EvenOddOptions());
927 } else {
928 CPDFSDK_BAAnnot::DrawAppearance(pDevice, mtUser2Device, mode);
929 }
930 }
931
UpdateField()932 void CPDFSDK_Widget::UpdateField() {
933 CPDF_FormField* pFormField = GetFormField();
934 DCHECK(pFormField);
935 m_pInteractiveForm->UpdateField(pFormField);
936 }
937
DrawShadow(CFX_RenderDevice * pDevice,CPDFSDK_PageView * pPageView)938 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice,
939 CPDFSDK_PageView* pPageView) {
940 FormFieldType fieldType = GetFieldType();
941 if (!m_pInteractiveForm->IsNeedHighLight(fieldType))
942 return;
943
944 CFX_Matrix page2device = pPageView->GetCurrentMatrix();
945 CFX_FloatRect rcDevice = GetRect();
946 CFX_PointF tmp =
947 page2device.Transform(CFX_PointF(rcDevice.left, rcDevice.bottom));
948 rcDevice.left = tmp.x;
949 rcDevice.bottom = tmp.y;
950
951 tmp = page2device.Transform(CFX_PointF(rcDevice.right, rcDevice.top));
952 rcDevice.right = tmp.x;
953 rcDevice.top = tmp.y;
954 rcDevice.Normalize();
955
956 pDevice->FillRect(
957 rcDevice.ToFxRect(),
958 AlphaAndColorRefToArgb(
959 static_cast<int>(m_pInteractiveForm->GetHighlightAlpha()),
960 m_pInteractiveForm->GetHighlightColor(fieldType)));
961 }
962
GetClientRect() const963 CFX_FloatRect CPDFSDK_Widget::GetClientRect() const {
964 CFX_FloatRect rcWindow = GetRotatedRect();
965 float fBorderWidth = GetBorderWidth();
966 switch (GetBorderStyle()) {
967 case BorderStyle::kBeveled:
968 case BorderStyle::kInset:
969 fBorderWidth *= 2.0f;
970 break;
971 default:
972 break;
973 }
974 return rcWindow.GetDeflated(fBorderWidth, fBorderWidth);
975 }
976
GetRotatedRect() const977 CFX_FloatRect CPDFSDK_Widget::GetRotatedRect() const {
978 CFX_FloatRect rectAnnot = GetRect();
979 float fWidth = rectAnnot.Width();
980 float fHeight = rectAnnot.Height();
981
982 CPDF_FormControl* pControl = GetFormControl();
983 CFX_FloatRect rcPWLWindow;
984 switch (abs(pControl->GetRotation() % 360)) {
985 case 0:
986 case 180:
987 default:
988 rcPWLWindow = CFX_FloatRect(0, 0, fWidth, fHeight);
989 break;
990 case 90:
991 case 270:
992 rcPWLWindow = CFX_FloatRect(0, 0, fHeight, fWidth);
993 break;
994 }
995
996 return rcPWLWindow;
997 }
998
GetMatrix() const999 CFX_Matrix CPDFSDK_Widget::GetMatrix() const {
1000 CFX_Matrix mt;
1001 CPDF_FormControl* pControl = GetFormControl();
1002 CFX_FloatRect rcAnnot = GetRect();
1003 float fWidth = rcAnnot.Width();
1004 float fHeight = rcAnnot.Height();
1005
1006 switch (abs(pControl->GetRotation() % 360)) {
1007 default:
1008 case 0:
1009 break;
1010 case 90:
1011 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0);
1012 break;
1013 case 180:
1014 mt = CFX_Matrix(-1, 0, 0, -1, fWidth, fHeight);
1015 break;
1016 case 270:
1017 mt = CFX_Matrix(0, -1, 1, 0, 0, fHeight);
1018 break;
1019 }
1020
1021 return mt;
1022 }
1023
GetTextPWLColor() const1024 CFX_Color CPDFSDK_Widget::GetTextPWLColor() const {
1025 CPDF_FormControl* pFormCtrl = GetFormControl();
1026 absl::optional<CFX_Color> crText =
1027 pFormCtrl->GetDefaultAppearance().GetColor();
1028 return crText.value_or(CFX_Color(CFX_Color::Type::kGray, 0));
1029 }
1030
GetBorderPWLColor() const1031 CFX_Color CPDFSDK_Widget::GetBorderPWLColor() const {
1032 CPDF_FormControl* pFormCtrl = GetFormControl();
1033 return pFormCtrl->GetOriginalBorderColor();
1034 }
1035
GetFillPWLColor() const1036 CFX_Color CPDFSDK_Widget::GetFillPWLColor() const {
1037 CPDF_FormControl* pFormCtrl = GetFormControl();
1038 return pFormCtrl->GetOriginalBackgroundColor();
1039 }
1040
OnAAction(CPDF_AAction::AActionType type,CFFL_FieldAction * data,const CPDFSDK_PageView * pPageView)1041 bool CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
1042 CFFL_FieldAction* data,
1043 const CPDFSDK_PageView* pPageView) {
1044 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
1045
1046 #ifdef PDF_ENABLE_XFA
1047 if (HandleXFAAAction(type, data, pFormFillEnv))
1048 return true;
1049 #endif // PDF_ENABLE_XFA
1050
1051 CPDF_Action action = GetAAction(type);
1052 if (action.GetType() != CPDF_Action::Type::kUnknown) {
1053 pFormFillEnv->DoActionField(action, type, GetFormField(), data);
1054 }
1055 return false;
1056 }
1057
OnLoad()1058 void CPDFSDK_Widget::OnLoad() {
1059 if (IsSignatureWidget())
1060 return;
1061
1062 if (!IsAppearanceValid())
1063 ResetAppearance(absl::nullopt, CPDFSDK_Widget::kValueUnchanged);
1064
1065 FormFieldType field_type = GetFieldType();
1066 if (field_type == FormFieldType::kTextField ||
1067 field_type == FormFieldType::kComboBox) {
1068 ObservedPtr<CPDFSDK_Annot> pObserved(this);
1069 absl::optional<WideString> sValue = OnFormat();
1070 if (!pObserved)
1071 return;
1072
1073 if (sValue.has_value() && field_type == FormFieldType::kComboBox)
1074 ResetAppearance(sValue, CPDFSDK_Widget::kValueUnchanged);
1075 }
1076
1077 #ifdef PDF_ENABLE_XFA
1078 auto* pContext = GetPageView()->GetFormFillEnv()->GetDocExtension();
1079 if (pContext && pContext->ContainsExtensionForegroundForm()) {
1080 if (!IsAppearanceValid() && !GetValue().IsEmpty())
1081 ResetXFAAppearance(CPDFSDK_Widget::kValueUnchanged);
1082 }
1083 #endif // PDF_ENABLE_XFA
1084 }
1085
GetAAction(CPDF_AAction::AActionType eAAT)1086 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) {
1087 switch (eAAT) {
1088 case CPDF_AAction::kCursorEnter:
1089 case CPDF_AAction::kCursorExit:
1090 case CPDF_AAction::kButtonDown:
1091 case CPDF_AAction::kButtonUp:
1092 case CPDF_AAction::kGetFocus:
1093 case CPDF_AAction::kLoseFocus:
1094 case CPDF_AAction::kPageOpen:
1095 case CPDF_AAction::kPageClose:
1096 case CPDF_AAction::kPageVisible:
1097 case CPDF_AAction::kPageInvisible:
1098 return CPDFSDK_BAAnnot::GetAAction(eAAT);
1099
1100 case CPDF_AAction::kKeyStroke:
1101 case CPDF_AAction::kFormat:
1102 case CPDF_AAction::kValidate:
1103 case CPDF_AAction::kCalculate: {
1104 CPDF_FormField* pField = GetFormField();
1105 if (pField->GetAdditionalAction().HasDict())
1106 return pField->GetAdditionalAction().GetAction(eAAT);
1107 return CPDFSDK_BAAnnot::GetAAction(eAAT);
1108 }
1109 default:
1110 break;
1111 }
1112
1113 return CPDF_Action(nullptr);
1114 }
1115
GetInteractiveFormFiller()1116 CFFL_InteractiveFormFiller* CPDFSDK_Widget::GetInteractiveFormFiller() {
1117 return GetPageView()->GetFormFillEnv()->GetInteractiveFormFiller();
1118 }
1119