1 // Copyright 2014 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/formfiller/cffl_formfield.h"
8
9 #include <utility>
10
11 #include "constants/form_flags.h"
12 #include "core/fpdfapi/page/cpdf_page.h"
13 #include "core/fxge/cfx_renderdevice.h"
14 #include "fpdfsdk/cpdfsdk_pageview.h"
15 #include "fpdfsdk/cpdfsdk_widget.h"
16 #include "fpdfsdk/formfiller/cffl_perwindowdata.h"
17 #include "third_party/base/check.h"
18
CFFL_FormField(CFFL_InteractiveFormFiller * pFormFiller,CPDFSDK_Widget * pWidget)19 CFFL_FormField::CFFL_FormField(CFFL_InteractiveFormFiller* pFormFiller,
20 CPDFSDK_Widget* pWidget)
21 : m_pFormFiller(pFormFiller), m_pWidget(pWidget) {
22 DCHECK(m_pFormFiller);
23 }
24
~CFFL_FormField()25 CFFL_FormField::~CFFL_FormField() {
26 DestroyWindows();
27 }
28
DestroyWindows()29 void CFFL_FormField::DestroyWindows() {
30 while (!m_Maps.empty()) {
31 auto it = m_Maps.begin();
32 std::unique_ptr<CPWL_Wnd> pWnd = std::move(it->second);
33 m_Maps.erase(it);
34 pWnd->InvalidateProvider(this);
35 pWnd->Destroy();
36 }
37 }
38
GetViewBBox(const CPDFSDK_PageView * pPageView)39 FX_RECT CFFL_FormField::GetViewBBox(const CPDFSDK_PageView* pPageView) {
40 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
41 CFX_FloatRect rcAnnot =
42 pWnd ? PWLtoFFL(pWnd->GetWindowRect()) : m_pWidget->GetRect();
43 CFX_FloatRect rcFocus = GetFocusBox(pPageView);
44
45 CFX_FloatRect rcWin = rcAnnot;
46 if (!rcFocus.IsEmpty())
47 rcWin.Union(rcFocus);
48 if (!rcWin.IsEmpty()) {
49 rcWin.Inflate(1, 1);
50 rcWin.Normalize();
51 }
52
53 return rcWin.GetOuterRect();
54 }
55
OnDraw(CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,CFX_RenderDevice * pDevice,const CFX_Matrix & mtUser2Device)56 void CFFL_FormField::OnDraw(CPDFSDK_PageView* pPageView,
57 CPDFSDK_Widget* pWidget,
58 CFX_RenderDevice* pDevice,
59 const CFX_Matrix& mtUser2Device) {
60 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
61 if (pWnd) {
62 pWnd->DrawAppearance(pDevice, GetCurMatrix() * mtUser2Device);
63 return;
64 }
65 if (!CFFL_InteractiveFormFiller::IsVisible(pWidget))
66 return;
67
68 pWidget->DrawAppearance(pDevice, mtUser2Device,
69 CPDF_Annot::AppearanceMode::kNormal);
70 }
71
OnDrawDeactive(CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,CFX_RenderDevice * pDevice,const CFX_Matrix & mtUser2Device)72 void CFFL_FormField::OnDrawDeactive(CPDFSDK_PageView* pPageView,
73 CPDFSDK_Widget* pWidget,
74 CFX_RenderDevice* pDevice,
75 const CFX_Matrix& mtUser2Device) {
76 pWidget->DrawAppearance(pDevice, mtUser2Device,
77 CPDF_Annot::AppearanceMode::kNormal);
78 }
79
OnMouseEnter(CPDFSDK_PageView * pPageView)80 void CFFL_FormField::OnMouseEnter(CPDFSDK_PageView* pPageView) {}
81
OnMouseExit(CPDFSDK_PageView * pPageView)82 void CFFL_FormField::OnMouseExit(CPDFSDK_PageView* pPageView) {
83 m_pTimer.reset();
84 DCHECK(m_pWidget);
85 }
86
OnLButtonDown(CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)87 bool CFFL_FormField::OnLButtonDown(CPDFSDK_PageView* pPageView,
88 CPDFSDK_Widget* pWidget,
89 Mask<FWL_EVENTFLAG> nFlags,
90 const CFX_PointF& point) {
91 CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
92 if (!pWnd)
93 return false;
94
95 m_bValid = true;
96 FX_RECT rect = GetViewBBox(pPageView);
97 InvalidateRect(rect);
98 if (!rect.Contains(static_cast<int>(point.x), static_cast<int>(point.y)))
99 return false;
100 return pWnd->OnLButtonDown(nFlags, FFLtoPWL(point));
101 }
102
OnLButtonUp(CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)103 bool CFFL_FormField::OnLButtonUp(CPDFSDK_PageView* pPageView,
104 CPDFSDK_Widget* pWidget,
105 Mask<FWL_EVENTFLAG> nFlags,
106 const CFX_PointF& point) {
107 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
108 if (!pWnd)
109 return false;
110
111 InvalidateRect(GetViewBBox(pPageView));
112 pWnd->OnLButtonUp(nFlags, FFLtoPWL(point));
113 return true;
114 }
115
OnLButtonDblClk(CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)116 bool CFFL_FormField::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
117 Mask<FWL_EVENTFLAG> nFlags,
118 const CFX_PointF& point) {
119 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
120 if (!pWnd)
121 return false;
122
123 pWnd->OnLButtonDblClk(nFlags, FFLtoPWL(point));
124 return true;
125 }
126
OnMouseMove(CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)127 bool CFFL_FormField::OnMouseMove(CPDFSDK_PageView* pPageView,
128 Mask<FWL_EVENTFLAG> nFlags,
129 const CFX_PointF& point) {
130 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
131 if (!pWnd)
132 return false;
133
134 pWnd->OnMouseMove(nFlags, FFLtoPWL(point));
135 return true;
136 }
137
OnMouseWheel(CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point,const CFX_Vector & delta)138 bool CFFL_FormField::OnMouseWheel(CPDFSDK_PageView* pPageView,
139 Mask<FWL_EVENTFLAG> nFlags,
140 const CFX_PointF& point,
141 const CFX_Vector& delta) {
142 if (!IsValid())
143 return false;
144
145 CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
146 return pWnd && pWnd->OnMouseWheel(nFlags, FFLtoPWL(point), delta);
147 }
148
OnRButtonDown(CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)149 bool CFFL_FormField::OnRButtonDown(CPDFSDK_PageView* pPageView,
150 Mask<FWL_EVENTFLAG> nFlags,
151 const CFX_PointF& point) {
152 CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
153 return pWnd && pWnd->OnRButtonDown(nFlags, FFLtoPWL(point));
154 }
155
OnRButtonUp(CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)156 bool CFFL_FormField::OnRButtonUp(CPDFSDK_PageView* pPageView,
157 Mask<FWL_EVENTFLAG> nFlags,
158 const CFX_PointF& point) {
159 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
160 return pWnd && pWnd->OnRButtonUp(nFlags, FFLtoPWL(point));
161 }
162
OnKeyDown(FWL_VKEYCODE nKeyCode,Mask<FWL_EVENTFLAG> nFlags)163 bool CFFL_FormField::OnKeyDown(FWL_VKEYCODE nKeyCode,
164 Mask<FWL_EVENTFLAG> nFlags) {
165 if (!IsValid())
166 return false;
167
168 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
169 return pWnd && pWnd->OnKeyDown(nKeyCode, nFlags);
170 }
171
OnChar(CPDFSDK_Widget * pWidget,uint32_t nChar,Mask<FWL_EVENTFLAG> nFlags)172 bool CFFL_FormField::OnChar(CPDFSDK_Widget* pWidget,
173 uint32_t nChar,
174 Mask<FWL_EVENTFLAG> nFlags) {
175 if (!IsValid())
176 return false;
177
178 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
179 return pWnd && pWnd->OnChar(nChar, nFlags);
180 }
181
SetIndexSelected(int index,bool selected)182 bool CFFL_FormField::SetIndexSelected(int index, bool selected) {
183 return false;
184 }
185
IsIndexSelected(int index)186 bool CFFL_FormField::IsIndexSelected(int index) {
187 return false;
188 }
189
GetText()190 WideString CFFL_FormField::GetText() {
191 if (!IsValid())
192 return WideString();
193
194 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
195 return pWnd ? pWnd->GetText() : WideString();
196 }
197
GetSelectedText()198 WideString CFFL_FormField::GetSelectedText() {
199 if (!IsValid())
200 return WideString();
201
202 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
203 return pWnd ? pWnd->GetSelectedText() : WideString();
204 }
205
ReplaceAndKeepSelection(const WideString & text)206 void CFFL_FormField::ReplaceAndKeepSelection(const WideString& text) {
207 if (!IsValid())
208 return;
209
210 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
211 if (!pWnd)
212 return;
213
214 pWnd->ReplaceAndKeepSelection(text);
215 }
216
ReplaceSelection(const WideString & text)217 void CFFL_FormField::ReplaceSelection(const WideString& text) {
218 if (!IsValid())
219 return;
220
221 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
222 if (!pWnd)
223 return;
224
225 pWnd->ReplaceSelection(text);
226 }
227
SelectAllText()228 bool CFFL_FormField::SelectAllText() {
229 if (!IsValid())
230 return false;
231
232 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
233 return pWnd && pWnd->SelectAllText();
234 }
235
CanUndo()236 bool CFFL_FormField::CanUndo() {
237 if (!IsValid())
238 return false;
239
240 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
241 return pWnd && pWnd->CanUndo();
242 }
243
CanRedo()244 bool CFFL_FormField::CanRedo() {
245 if (!IsValid())
246 return false;
247
248 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
249 return pWnd && pWnd->CanRedo();
250 }
251
Undo()252 bool CFFL_FormField::Undo() {
253 if (!IsValid())
254 return false;
255
256 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
257 return pWnd && pWnd->Undo();
258 }
259
Redo()260 bool CFFL_FormField::Redo() {
261 if (!IsValid())
262 return false;
263
264 CPWL_Wnd* pWnd = GetPWLWindow(GetCurPageView());
265 return pWnd && pWnd->Redo();
266 }
267
SetFocusForAnnot(CPDFSDK_Widget * pWidget,Mask<FWL_EVENTFLAG> nFlag)268 void CFFL_FormField::SetFocusForAnnot(CPDFSDK_Widget* pWidget,
269 Mask<FWL_EVENTFLAG> nFlag) {
270 CPDFSDK_PageView* pPageView =
271 m_pFormFiller->GetOrCreatePageView(pWidget->GetPage());
272 CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
273 if (pWnd)
274 pWnd->SetFocus();
275
276 m_bValid = true;
277 InvalidateRect(GetViewBBox(pPageView));
278 }
279
KillFocusForAnnot(Mask<FWL_EVENTFLAG> nFlag)280 void CFFL_FormField::KillFocusForAnnot(Mask<FWL_EVENTFLAG> nFlag) {
281 if (!IsValid())
282 return;
283
284 CPDFSDK_PageView* pPageView =
285 m_pFormFiller->GetPageView(m_pWidget->GetPage());
286 if (!pPageView || !CommitData(pPageView, nFlag))
287 return;
288 if (CPWL_Wnd* pWnd = GetPWLWindow(pPageView))
289 pWnd->KillFocus();
290
291 bool bDestroyPWLWindow;
292 switch (m_pWidget->GetFieldType()) {
293 case FormFieldType::kPushButton:
294 case FormFieldType::kCheckBox:
295 case FormFieldType::kRadioButton:
296 bDestroyPWLWindow = true;
297 break;
298 default:
299 bDestroyPWLWindow = false;
300 break;
301 }
302 EscapeFiller(pPageView, bDestroyPWLWindow);
303 }
304
IsValid() const305 bool CFFL_FormField::IsValid() const {
306 return m_bValid;
307 }
308
GetCreateParam()309 CPWL_Wnd::CreateParams CFFL_FormField::GetCreateParam() {
310 CPWL_Wnd::CreateParams cp(m_pFormFiller->GetTimerHandler(), m_pFormFiller,
311 this);
312
313 cp.rcRectWnd = GetPDFAnnotRect();
314
315 uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
316 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
317 if (dwFieldFlag & pdfium::form_flags::kReadOnly)
318 dwCreateFlags |= PWS_READONLY;
319
320 absl::optional<FX_COLORREF> color = m_pWidget->GetFillColor();
321 if (color.has_value())
322 cp.sBackgroundColor = CFX_Color(color.value());
323 color = m_pWidget->GetBorderColor();
324 if (color.has_value())
325 cp.sBorderColor = CFX_Color(color.value());
326
327 cp.sTextColor = CFX_Color(CFX_Color::Type::kGray, 0);
328
329 color = m_pWidget->GetTextColor();
330 if (color.has_value())
331 cp.sTextColor = CFX_Color(color.value());
332
333 cp.fFontSize = m_pWidget->GetFontSize();
334 cp.dwBorderWidth = m_pWidget->GetBorderWidth();
335
336 cp.nBorderStyle = m_pWidget->GetBorderStyle();
337 switch (cp.nBorderStyle) {
338 case BorderStyle::kDash:
339 cp.sDash = CPWL_Dash(3, 3, 0);
340 break;
341 case BorderStyle::kBeveled:
342 case BorderStyle::kInset:
343 cp.dwBorderWidth *= 2;
344 break;
345 default:
346 break;
347 }
348
349 if (cp.fFontSize <= 0)
350 dwCreateFlags |= PWS_AUTOFONTSIZE;
351
352 cp.dwFlags = dwCreateFlags;
353 return cp;
354 }
355
GetPWLWindow(const CPDFSDK_PageView * pPageView) const356 CPWL_Wnd* CFFL_FormField::GetPWLWindow(
357 const CPDFSDK_PageView* pPageView) const {
358 DCHECK(pPageView);
359 auto it = m_Maps.find(pPageView);
360 return it != m_Maps.end() ? it->second.get() : nullptr;
361 }
362
CreateOrUpdatePWLWindow(const CPDFSDK_PageView * pPageView)363 CPWL_Wnd* CFFL_FormField::CreateOrUpdatePWLWindow(
364 const CPDFSDK_PageView* pPageView) {
365 DCHECK(pPageView);
366 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
367 if (!pWnd) {
368 CPWL_Wnd::CreateParams cp = GetCreateParam();
369 // TODO(tsepez): maybe pass widget's value age as 4th arg.
370 auto pPrivateData = std::make_unique<CFFL_PerWindowData>(
371 m_pWidget, pPageView, m_pWidget->GetAppearanceAge(), 0);
372 m_Maps[pPageView] = NewPWLWindow(cp, std::move(pPrivateData));
373 return m_Maps[pPageView].get();
374 }
375 const auto* pPrivateData =
376 static_cast<const CFFL_PerWindowData*>(pWnd->GetAttachedData());
377 if (pPrivateData->AppearanceAgeEquals(m_pWidget->GetAppearanceAge()))
378 return pWnd;
379
380 return ResetPWLWindowForValueAgeInternal(pPageView, m_pWidget,
381 pPrivateData->GetValueAge());
382 }
383
DestroyPWLWindow(const CPDFSDK_PageView * pPageView)384 void CFFL_FormField::DestroyPWLWindow(const CPDFSDK_PageView* pPageView) {
385 auto it = m_Maps.find(pPageView);
386 if (it == m_Maps.end())
387 return;
388
389 std::unique_ptr<CPWL_Wnd> pWnd = std::move(it->second);
390 m_Maps.erase(it);
391 pWnd->Destroy();
392 }
393
GetWindowMatrix(const IPWL_FillerNotify::PerWindowData * pAttached)394 CFX_Matrix CFFL_FormField::GetWindowMatrix(
395 const IPWL_FillerNotify::PerWindowData* pAttached) {
396 const auto* pPrivateData = static_cast<const CFFL_PerWindowData*>(pAttached);
397 if (!pPrivateData)
398 return CFX_Matrix();
399
400 const CPDFSDK_PageView* pPageView = pPrivateData->GetPageView();
401 if (!pPageView)
402 return CFX_Matrix();
403
404 return GetCurMatrix() * pPageView->GetCurrentMatrix();
405 }
406
OnSetFocusForEdit(CPWL_Edit * pEdit)407 void CFFL_FormField::OnSetFocusForEdit(CPWL_Edit* pEdit) {
408 // Only sub-classes might have a subordinate edit to focus.
409 }
410
GetCurMatrix()411 CFX_Matrix CFFL_FormField::GetCurMatrix() {
412 CFX_Matrix mt;
413 CFX_FloatRect rcDA = m_pWidget->GetPDFAnnot()->GetRect();
414 switch (m_pWidget->GetRotate()) {
415 case 90:
416 mt = CFX_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0);
417 break;
418 case 180:
419 mt = CFX_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left,
420 rcDA.top - rcDA.bottom);
421 break;
422 case 270:
423 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom);
424 break;
425 case 0:
426 default:
427 break;
428 }
429 mt.e += rcDA.left;
430 mt.f += rcDA.bottom;
431
432 return mt;
433 }
434
GetPDFAnnotRect() const435 CFX_FloatRect CFFL_FormField::GetPDFAnnotRect() const {
436 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect();
437 float fWidth = rectAnnot.Width();
438 float fHeight = rectAnnot.Height();
439 if ((m_pWidget->GetRotate() / 90) & 0x01)
440 std::swap(fWidth, fHeight);
441 return CFX_FloatRect(0, 0, fWidth, fHeight);
442 }
443
GetCurPageView()444 CPDFSDK_PageView* CFFL_FormField::GetCurPageView() {
445 return m_pFormFiller->GetOrCreatePageView(m_pWidget->GetPage());
446 }
447
GetFocusBox(const CPDFSDK_PageView * pPageView)448 CFX_FloatRect CFFL_FormField::GetFocusBox(const CPDFSDK_PageView* pPageView) {
449 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
450 if (!pWnd)
451 return CFX_FloatRect();
452
453 CFX_FloatRect rcFocus = PWLtoFFL(pWnd->GetFocusRect());
454 return pPageView->GetPDFPage()->GetBBox().Contains(rcFocus) ? rcFocus
455 : CFX_FloatRect();
456 }
457
FFLtoPWL(const CFX_FloatRect & rect)458 CFX_FloatRect CFFL_FormField::FFLtoPWL(const CFX_FloatRect& rect) {
459 return GetCurMatrix().GetInverse().TransformRect(rect);
460 }
461
PWLtoFFL(const CFX_FloatRect & rect)462 CFX_FloatRect CFFL_FormField::PWLtoFFL(const CFX_FloatRect& rect) {
463 return GetCurMatrix().TransformRect(rect);
464 }
465
FFLtoPWL(const CFX_PointF & point)466 CFX_PointF CFFL_FormField::FFLtoPWL(const CFX_PointF& point) {
467 return GetCurMatrix().GetInverse().Transform(point);
468 }
469
PWLtoFFL(const CFX_PointF & point)470 CFX_PointF CFFL_FormField::PWLtoFFL(const CFX_PointF& point) {
471 return GetCurMatrix().Transform(point);
472 }
473
CommitData(const CPDFSDK_PageView * pPageView,Mask<FWL_EVENTFLAG> nFlag)474 bool CFFL_FormField::CommitData(const CPDFSDK_PageView* pPageView,
475 Mask<FWL_EVENTFLAG> nFlag) {
476 if (!IsDataChanged(pPageView))
477 return true;
478
479 ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget);
480 if (!m_pFormFiller->OnKeyStrokeCommit(pObserved, pPageView, nFlag)) {
481 if (!pObserved)
482 return false;
483 ResetPWLWindow(pPageView);
484 return true;
485 }
486 if (!pObserved)
487 return false;
488
489 if (!m_pFormFiller->OnValidate(pObserved, pPageView, nFlag)) {
490 if (!pObserved)
491 return false;
492 ResetPWLWindow(pPageView);
493 return true;
494 }
495 if (!pObserved)
496 return false;
497
498 SaveData(pPageView); // may invoking JS to delete this widget.
499 if (!pObserved)
500 return false;
501
502 m_pFormFiller->OnCalculate(pObserved);
503 if (!pObserved)
504 return false;
505
506 m_pFormFiller->OnFormat(pObserved);
507 if (!pObserved)
508 return false;
509
510 return true;
511 }
512
IsDataChanged(const CPDFSDK_PageView * pPageView)513 bool CFFL_FormField::IsDataChanged(const CPDFSDK_PageView* pPageView) {
514 return false;
515 }
516
SaveData(const CPDFSDK_PageView * pPageView)517 void CFFL_FormField::SaveData(const CPDFSDK_PageView* pPageView) {}
518
519 #ifdef PDF_ENABLE_XFA
IsFieldFull(const CPDFSDK_PageView * pPageView)520 bool CFFL_FormField::IsFieldFull(const CPDFSDK_PageView* pPageView) {
521 return false;
522 }
523 #endif // PDF_ENABLE_XFA
524
SetChangeMark()525 void CFFL_FormField::SetChangeMark() {
526 m_pFormFiller->OnChange();
527 }
528
GetActionData(const CPDFSDK_PageView * pPageView,CPDF_AAction::AActionType type,CFFL_FieldAction & fa)529 void CFFL_FormField::GetActionData(const CPDFSDK_PageView* pPageView,
530 CPDF_AAction::AActionType type,
531 CFFL_FieldAction& fa) {
532 fa.sValue = m_pWidget->GetValue();
533 }
534
SetActionData(const CPDFSDK_PageView * pPageView,CPDF_AAction::AActionType type,const CFFL_FieldAction & fa)535 void CFFL_FormField::SetActionData(const CPDFSDK_PageView* pPageView,
536 CPDF_AAction::AActionType type,
537 const CFFL_FieldAction& fa) {}
538
SavePWLWindowState(const CPDFSDK_PageView * pPageView)539 void CFFL_FormField::SavePWLWindowState(const CPDFSDK_PageView* pPageView) {}
540
RecreatePWLWindowFromSavedState(const CPDFSDK_PageView * pPageView)541 void CFFL_FormField::RecreatePWLWindowFromSavedState(
542 const CPDFSDK_PageView* pPageView) {}
543
GetPerPWLWindowData(const CPDFSDK_PageView * pPageView)544 CFFL_PerWindowData* CFFL_FormField::GetPerPWLWindowData(
545 const CPDFSDK_PageView* pPageView) {
546 CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
547 if (!pWnd)
548 return nullptr;
549
550 return static_cast<CFFL_PerWindowData*>(pWnd->GetAttachedData());
551 }
552
ResetPWLWindowForValueAge(const CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,uint32_t nValueAge)553 void CFFL_FormField::ResetPWLWindowForValueAge(
554 const CPDFSDK_PageView* pPageView,
555 CPDFSDK_Widget* pWidget,
556 uint32_t nValueAge) {
557 // Don't leak PWL_Wnd result to public callers.
558 ResetPWLWindowForValueAgeInternal(pPageView, pWidget, nValueAge);
559 }
560
ResetPWLWindowForValueAgeInternal(const CPDFSDK_PageView * pPageView,CPDFSDK_Widget * pWidget,uint32_t nValueAge)561 CPWL_Wnd* CFFL_FormField::ResetPWLWindowForValueAgeInternal(
562 const CPDFSDK_PageView* pPageView,
563 CPDFSDK_Widget* pWidget,
564 uint32_t nValueAge) {
565 return nValueAge == pWidget->GetValueAge() ? RestorePWLWindow(pPageView)
566 : ResetPWLWindow(pPageView);
567 }
568
ResetPWLWindow(const CPDFSDK_PageView * pPageView)569 CPWL_Wnd* CFFL_FormField::ResetPWLWindow(const CPDFSDK_PageView* pPageView) {
570 return GetPWLWindow(pPageView);
571 }
572
RestorePWLWindow(const CPDFSDK_PageView * pPageView)573 CPWL_Wnd* CFFL_FormField::RestorePWLWindow(const CPDFSDK_PageView* pPageView) {
574 return GetPWLWindow(pPageView);
575 }
576
OnTimerFired()577 void CFFL_FormField::OnTimerFired() {}
578
EscapeFiller(CPDFSDK_PageView * pPageView,bool bDestroyPWLWindow)579 void CFFL_FormField::EscapeFiller(CPDFSDK_PageView* pPageView,
580 bool bDestroyPWLWindow) {
581 m_bValid = false;
582
583 InvalidateRect(GetViewBBox(pPageView));
584 if (bDestroyPWLWindow)
585 DestroyPWLWindow(pPageView);
586 }
587
InvalidateRect(const FX_RECT & rect)588 void CFFL_FormField::InvalidateRect(const FX_RECT& rect) {
589 m_pFormFiller->Invalidate(m_pWidget->GetPage(), rect);
590 }
591