• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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.
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 CPWL_Wnd::FocusHandlerIface {
24  public:
25   CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, 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_SystemHandler::PerWindowData> pAttachedData)
33       override;
34   bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
35   bool IsDataChanged(CPDFSDK_PageView* pPageView) override;
36   void SaveData(CPDFSDK_PageView* pPageView) override;
37   void GetActionData(CPDFSDK_PageView* pPageView,
38                      CPDF_AAction::AActionType type,
39                      CPDFSDK_FieldAction& fa) override;
40   void SetActionData(CPDFSDK_PageView* pPageView,
41                      CPDF_AAction::AActionType type,
42                      const CPDFSDK_FieldAction& fa) override;
43   void SaveState(CPDFSDK_PageView* pPageView) override;
44   void RestoreState(CPDFSDK_PageView* pPageView) override;
45 #ifdef PDF_ENABLE_XFA
46   bool IsFieldFull(CPDFSDK_PageView* pPageView) override;
47 #endif
48 
49   // CPWL_Wnd::FocusHandlerIface:
50   void OnSetFocus(CPWL_Edit* pEdit) override;
51 
52  private:
53   CPWL_Edit* GetEdit(CPDFSDK_PageView* pPageView, bool bNew);
54 
55   FFL_TextFieldState m_State;
56 };
57 
58 #endif  // FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_
59