• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COMBOBOX_H_
8 #define FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/widestring.h"
13 #include "fpdfsdk/formfiller/cffl_textobject.h"
14 
15 class CPWL_ComboBox;
16 
17 struct FFL_ComboBoxState {
18   int nIndex = 0;
19   int nStart = 0;
20   int nEnd = 0;
21   WideString sValue;
22 };
23 
24 class CFFL_ComboBox final : public CFFL_TextObject {
25  public:
26   CFFL_ComboBox(CFFL_InteractiveFormFiller* pFormFiller,
27                 CPDFSDK_Widget* pWidget);
28   ~CFFL_ComboBox() override;
29 
30   // CFFL_TextObject:
31   CPWL_Wnd::CreateParams GetCreateParam() override;
32   std::unique_ptr<CPWL_Wnd> NewPWLWindow(
33       const CPWL_Wnd::CreateParams& cp,
34       std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) override;
35   bool OnChar(CPDFSDK_Widget* pWidget,
36               uint32_t nChar,
37               Mask<FWL_EVENTFLAG> nFlags) override;
38   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
39   void SaveData(const CPDFSDK_PageView* pPageView) override;
40   void GetActionData(const CPDFSDK_PageView* pPageView,
41                      CPDF_AAction::AActionType type,
42                      CFFL_FieldAction& fa) override;
43   void SetActionData(const CPDFSDK_PageView* pPageView,
44                      CPDF_AAction::AActionType type,
45                      const CFFL_FieldAction& fa) override;
46   void SavePWLWindowState(const CPDFSDK_PageView* pPageView) override;
47   void RecreatePWLWindowFromSavedState(
48       const CPDFSDK_PageView* pPageView) override;
49   bool SetIndexSelected(int index, bool selected) override;
50   bool IsIndexSelected(int index) override;
51 #ifdef PDF_ENABLE_XFA
52   bool IsFieldFull(const CPDFSDK_PageView* pPageView) override;
53 #endif
54 
55   // CPWL_Wnd::ProviderIface:
56   void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
57 
58  private:
59   WideString GetSelectExportText();
60   CPWL_ComboBox* GetPWLComboBox(const CPDFSDK_PageView* pPageView) const;
61   CPWL_ComboBox* CreateOrUpdatePWLComboBox(const CPDFSDK_PageView* pPageView);
62 
63   FFL_ComboBoxState m_State;
64 };
65 
66 #endif  // FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
67