• 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_INCLUDE_FORMFILLER_FFL_FORMFILLER_H_
8 #define FPDFSDK_INCLUDE_FORMFILLER_FFL_FORMFILLER_H_
9 
10 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
11 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h"
12 #include "fpdfsdk/include/fsdk_baseform.h"
13 
14 class CPDFDoc_Environment;
15 class CPDFSDK_Annot;
16 class CPDFSDK_Document;
17 class CPDFSDK_PageView;
18 class CPDFSDK_Widget;
19 
20 class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
21  public:
22   CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot);
23   ~CFFL_FormFiller() override;
24 
25   virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView,
26                               CPDFSDK_Annot* pAnnot);
27   virtual void OnDraw(CPDFSDK_PageView* pPageView,
28                       CPDFSDK_Annot* pAnnot,
29                       CFX_RenderDevice* pDevice,
30                       CFX_Matrix* pUser2Device,
31                       FX_DWORD dwFlags);
32   virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView,
33                               CPDFSDK_Annot* pAnnot,
34                               CFX_RenderDevice* pDevice,
35                               CFX_Matrix* pUser2Device,
36                               FX_DWORD dwFlags);
37 
38   virtual void OnCreate(CPDFSDK_Annot* pAnnot);
39   virtual void OnLoad(CPDFSDK_Annot* pAnnot);
40   virtual void OnDelete(CPDFSDK_Annot* pAnnot);
41 
42   virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot);
43   virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot);
44 
45   virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView,
46                                 CPDFSDK_Annot* pAnnot,
47                                 FX_UINT nFlags,
48                                 const CPDF_Point& point);
49   virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView,
50                               CPDFSDK_Annot* pAnnot,
51                               FX_UINT nFlags,
52                               const CPDF_Point& point);
53   virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView,
54                                   CPDFSDK_Annot* pAnnot,
55                                   FX_UINT nFlags,
56                                   const CPDF_Point& point);
57   virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView,
58                               CPDFSDK_Annot* pAnnot,
59                               FX_UINT nFlags,
60                               const CPDF_Point& point);
61   virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView,
62                                CPDFSDK_Annot* pAnnot,
63                                FX_UINT nFlags,
64                                short zDelta,
65                                const CPDF_Point& point);
66   virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView,
67                                 CPDFSDK_Annot* pAnnot,
68                                 FX_UINT nFlags,
69                                 const CPDF_Point& point);
70   virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView,
71                               CPDFSDK_Annot* pAnnot,
72                               FX_UINT nFlags,
73                               const CPDF_Point& point);
74 
75   virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot,
76                             FX_UINT nKeyCode,
77                             FX_UINT nFlags);
78   virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags);
79 
80   void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
81   void KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
82 
83   // CPWL_TimerHandler
84   void TimerProc() override;
85   IFX_SystemHandler* GetSystemHandler() const override;
86 
87   // IPWL_Provider
88   CFX_Matrix GetWindowMatrix(void* pAttachedData) override;
89   CFX_WideString LoadPopupMenuString(int nIndex) override;
90 
91   virtual void GetActionData(CPDFSDK_PageView* pPageView,
92                              CPDF_AAction::AActionType type,
93                              PDFSDK_FieldAction& fa);
94   virtual void SetActionData(CPDFSDK_PageView* pPageView,
95                              CPDF_AAction::AActionType type,
96                              const PDFSDK_FieldAction& fa);
97   virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type,
98                                       const PDFSDK_FieldAction& faOld,
99                                       const PDFSDK_FieldAction& faNew);
100 
101   virtual void SaveState(CPDFSDK_PageView* pPageView);
102   virtual void RestoreState(CPDFSDK_PageView* pPageView);
103 
104   virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView,
105                                    FX_BOOL bRestoreValue);
106 
107   CFX_Matrix GetCurMatrix();
108 
109   CPDF_Rect FFLtoPWL(const CPDF_Rect& rect);
110   CPDF_Rect PWLtoFFL(const CPDF_Rect& rect);
111   CPDF_Point FFLtoPWL(const CPDF_Point& point);
112   CPDF_Point PWLtoFFL(const CPDF_Point& point);
113 
114   CPDF_Point WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt);
115   CPDF_Rect FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect& rect);
116 
117   void SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow);
118   CPDF_Rect GetWindowRect(CPDFSDK_PageView* pPageView);
119 
120   FX_BOOL CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag);
121   virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView);
122   virtual void SaveData(CPDFSDK_PageView* pPageView);
123 
124 #ifdef PDF_ENABLE_XFA
125   virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView);
126 #endif  // PDF_ENABLE_XFA
127 
128   CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew);
129   void DestroyPDFWindow(CPDFSDK_PageView* pPageView);
130   void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow);
131 
132   virtual PWL_CREATEPARAM GetCreateParam();
133   virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp,
134                                  CPDFSDK_PageView* pPageView) = 0;
135   virtual CPDF_Rect GetFocusBox(CPDFSDK_PageView* pPageView);
136 
137   FX_BOOL IsValid() const;
138   CPDF_Rect GetPDFWindowRect() const;
139 
140   CPDFSDK_PageView* GetCurPageView();
141   void SetChangeMark();
142 
143   virtual void InvalidateRect(double left,
144                               double top,
145                               double right,
146                               double bottom);
GetApp()147   CPDFDoc_Environment* GetApp() { return m_pApp; }
GetSDKAnnot()148   CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; }
149 
150  protected:
151   using CFFL_PageView2PDFWindow = std::map<CPDFSDK_PageView*, CPWL_Wnd*>;
152 
153   CPDFDoc_Environment* m_pApp;
154   CPDFSDK_Widget* m_pWidget;
155   CPDFSDK_Annot* m_pAnnot;
156 
157   FX_BOOL m_bValid;
158   CFFL_PageView2PDFWindow m_Maps;
159   CPDF_Point m_ptOldPos;
160 };
161 
162 class CFFL_Button : public CFFL_FormFiller {
163  public:
164   CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget);
165   ~CFFL_Button() override;
166 
167   // CFFL_FormFiller
168   void OnMouseEnter(CPDFSDK_PageView* pPageView,
169                     CPDFSDK_Annot* pAnnot) override;
170   void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) override;
171   FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView,
172                         CPDFSDK_Annot* pAnnot,
173                         FX_UINT nFlags,
174                         const CPDF_Point& point) override;
175   FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView,
176                       CPDFSDK_Annot* pAnnot,
177                       FX_UINT nFlags,
178                       const CPDF_Point& point) override;
179   FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView,
180                       CPDFSDK_Annot* pAnnot,
181                       FX_UINT nFlags,
182                       const CPDF_Point& point) override;
183   void OnDraw(CPDFSDK_PageView* pPageView,
184               CPDFSDK_Annot* pAnnot,
185               CFX_RenderDevice* pDevice,
186               CFX_Matrix* pUser2Device,
187               FX_DWORD dwFlags) override;
188   void OnDrawDeactive(CPDFSDK_PageView* pPageView,
189                       CPDFSDK_Annot* pAnnot,
190                       CFX_RenderDevice* pDevice,
191                       CFX_Matrix* pUser2Device,
192                       FX_DWORD dwFlags) override;
193 
194  protected:
195   FX_BOOL m_bMouseIn;
196   FX_BOOL m_bMouseDown;
197 };
198 
199 #endif  // FPDFSDK_INCLUDE_FORMFILLER_FFL_FORMFILLER_H_
200