xref: /aosp_15_r20/external/pdfium/fpdfsdk/formfiller/cffl_textfield.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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 #ifndef FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_
8 #define FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_
9 
10 #include <memory>
11 
12 #include "fpdfsdk/formfiller/cffl_textobject.h"
13 
14 class CPWL_Edit;
15 
16 struct FFL_TextFieldState {
17   int nStart = 0;
18   int nEnd = 0;
19   WideString sValue;
20 };
21 
22 class CFFL_TextField final : public CFFL_TextObject {
23  public:
24   CFFL_TextField(CFFL_InteractiveFormFiller* pFormFiller,
25                  CPDFSDK_Widget* pWidget);
26   ~CFFL_TextField() override;
27 
28   // CFFL_TextObject:
29   CPWL_Wnd::CreateParams GetCreateParam() override;
30   std::unique_ptr<CPWL_Wnd> NewPWLWindow(
31       const CPWL_Wnd::CreateParams& cp,
32       std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) override;
33   bool OnChar(CPDFSDK_Widget* pWidget,
34               uint32_t nChar,
35               Mask<FWL_EVENTFLAG> nFlags) override;
36   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
37   void SaveData(const CPDFSDK_PageView* pPageView) override;
38   void GetActionData(const CPDFSDK_PageView* pPageView,
39                      CPDF_AAction::AActionType type,
40                      CFFL_FieldAction& fa) override;
41   void SetActionData(const CPDFSDK_PageView* pPageView,
42                      CPDF_AAction::AActionType type,
43                      const CFFL_FieldAction& fa) override;
44   void SavePWLWindowState(const CPDFSDK_PageView* pPageView) override;
45   void RecreatePWLWindowFromSavedState(
46       const CPDFSDK_PageView* pPageView) override;
47 #ifdef PDF_ENABLE_XFA
48   bool IsFieldFull(const CPDFSDK_PageView* pPageView) override;
49 #endif
50 
51   // CPWL_Wnd::ProviderIface:
52   void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
53 
54  private:
55   CPWL_Edit* GetPWLEdit(const CPDFSDK_PageView* pPageView) const;
56   CPWL_Edit* CreateOrUpdatePWLEdit(const CPDFSDK_PageView* pPageView);
57 
58   FFL_TextFieldState m_State;
59 };
60 
61 #endif  // FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_
62