| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ | 7 #ifndef FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ |
| 8 #define FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ | 8 #define FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 CFX_RenderDevice* pDevice, | 31 CFX_RenderDevice* pDevice, |
| 32 CFX_Matrix* pUser2Device); | 32 CFX_Matrix* pUser2Device); |
| 33 virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView, | 33 virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 34 CPDFSDK_Annot* pAnnot, | 34 CPDFSDK_Annot* pAnnot, |
| 35 CFX_RenderDevice* pDevice, | 35 CFX_RenderDevice* pDevice, |
| 36 CFX_Matrix* pUser2Device); | 36 CFX_Matrix* pUser2Device); |
| 37 | 37 |
| 38 virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); | 38 virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); |
| 39 virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); | 39 virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); |
| 40 | 40 |
| 41 virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, | 41 virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 42 CPDFSDK_Annot* pAnnot, | 42 CPDFSDK_Annot* pAnnot, |
| 43 uint32_t nFlags, | 43 uint32_t nFlags, |
| 44 const CFX_FloatPoint& point); | 44 const CFX_FloatPoint& point); |
| 45 virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, | 45 virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 46 CPDFSDK_Annot* pAnnot, | 46 CPDFSDK_Annot* pAnnot, |
| 47 uint32_t nFlags, | 47 uint32_t nFlags, |
| 48 const CFX_FloatPoint& point); | 48 const CFX_FloatPoint& point); |
| 49 virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 49 virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 50 CPDFSDK_Annot* pAnnot, | |
| 51 uint32_t nFlags, | |
| 52 const CFX_FloatPoint& point); | |
| 53 virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, | |
| 54 CPDFSDK_Annot* pAnnot, | |
| 55 uint32_t nFlags, | |
| 56 const CFX_FloatPoint& point); | |
| 57 virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, | |
| 58 CPDFSDK_Annot* pAnnot, | 50 CPDFSDK_Annot* pAnnot, |
| 59 uint32_t nFlags, | 51 uint32_t nFlags, |
| 60 short zDelta, | |
| 61 const CFX_FloatPoint& point); | 52 const CFX_FloatPoint& point); |
| 62 virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, | 53 virtual bool OnMouseMove(CPDFSDK_PageView* pPageView, |
| 63 CPDFSDK_Annot* pAnnot, | 54 CPDFSDK_Annot* pAnnot, |
| 64 uint32_t nFlags, | 55 uint32_t nFlags, |
| 65 const CFX_FloatPoint& point); | 56 const CFX_FloatPoint& point); |
| 66 virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, | 57 virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 67 CPDFSDK_Annot* pAnnot, | 58 CPDFSDK_Annot* pAnnot, |
| 68 uint32_t nFlags, | 59 uint32_t nFlags, |
| 69 const CFX_FloatPoint& point); | 60 short zDelta, |
| 61 const CFX_FloatPoint& point); |
| 62 virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 63 CPDFSDK_Annot* pAnnot, |
| 64 uint32_t nFlags, |
| 65 const CFX_FloatPoint& point); |
| 66 virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 67 CPDFSDK_Annot* pAnnot, |
| 68 uint32_t nFlags, |
| 69 const CFX_FloatPoint& point); |
| 70 | 70 |
| 71 virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, | 71 virtual bool OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 72 uint32_t nKeyCode, | 72 uint32_t nKeyCode, |
| 73 uint32_t nFlags); | |
| 74 virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, | |
| 75 uint32_t nChar, | |
| 76 uint32_t nFlags); | 73 uint32_t nFlags); |
| 74 virtual bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags); |
| 77 | 75 |
| 78 void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag); | 76 void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag); |
| 79 void KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag); | 77 void KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag); |
| 80 | 78 |
| 81 // CPWL_TimerHandler | 79 // CPWL_TimerHandler |
| 82 void TimerProc() override; | 80 void TimerProc() override; |
| 83 CFX_SystemHandler* GetSystemHandler() const override; | 81 CFX_SystemHandler* GetSystemHandler() const override; |
| 84 | 82 |
| 85 // IPWL_Provider | 83 // IPWL_Provider |
| 86 CFX_Matrix GetWindowMatrix(void* pAttachedData) override; | 84 CFX_Matrix GetWindowMatrix(void* pAttachedData) override; |
| 87 CFX_WideString LoadPopupMenuString(int nIndex) override; | 85 CFX_WideString LoadPopupMenuString(int nIndex) override; |
| 88 | 86 |
| 89 virtual void GetActionData(CPDFSDK_PageView* pPageView, | 87 virtual void GetActionData(CPDFSDK_PageView* pPageView, |
| 90 CPDF_AAction::AActionType type, | 88 CPDF_AAction::AActionType type, |
| 91 PDFSDK_FieldAction& fa); | 89 PDFSDK_FieldAction& fa); |
| 92 virtual void SetActionData(CPDFSDK_PageView* pPageView, | 90 virtual void SetActionData(CPDFSDK_PageView* pPageView, |
| 93 CPDF_AAction::AActionType type, | 91 CPDF_AAction::AActionType type, |
| 94 const PDFSDK_FieldAction& fa); | 92 const PDFSDK_FieldAction& fa); |
| 95 virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, | 93 virtual bool IsActionDataChanged(CPDF_AAction::AActionType type, |
| 96 const PDFSDK_FieldAction& faOld, | 94 const PDFSDK_FieldAction& faOld, |
| 97 const PDFSDK_FieldAction& faNew); | 95 const PDFSDK_FieldAction& faNew); |
| 98 | 96 |
| 99 virtual void SaveState(CPDFSDK_PageView* pPageView); | 97 virtual void SaveState(CPDFSDK_PageView* pPageView); |
| 100 virtual void RestoreState(CPDFSDK_PageView* pPageView); | 98 virtual void RestoreState(CPDFSDK_PageView* pPageView); |
| 101 | 99 |
| 102 virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, | 100 virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, |
| 103 FX_BOOL bRestoreValue); | 101 bool bRestoreValue); |
| 104 | 102 |
| 105 CFX_Matrix GetCurMatrix(); | 103 CFX_Matrix GetCurMatrix(); |
| 106 | 104 |
| 107 CFX_FloatRect FFLtoPWL(const CFX_FloatRect& rect); | 105 CFX_FloatRect FFLtoPWL(const CFX_FloatRect& rect); |
| 108 CFX_FloatRect PWLtoFFL(const CFX_FloatRect& rect); | 106 CFX_FloatRect PWLtoFFL(const CFX_FloatRect& rect); |
| 109 CFX_FloatPoint FFLtoPWL(const CFX_FloatPoint& point); | 107 CFX_FloatPoint FFLtoPWL(const CFX_FloatPoint& point); |
| 110 CFX_FloatPoint PWLtoFFL(const CFX_FloatPoint& point); | 108 CFX_FloatPoint PWLtoFFL(const CFX_FloatPoint& point); |
| 111 | 109 |
| 112 CFX_FloatPoint WndtoPWL(CPDFSDK_PageView* pPageView, | 110 CFX_FloatPoint WndtoPWL(CPDFSDK_PageView* pPageView, |
| 113 const CFX_FloatPoint& pt); | 111 const CFX_FloatPoint& pt); |
| 114 CFX_FloatRect FFLtoWnd(CPDFSDK_PageView* pPageView, | 112 CFX_FloatRect FFLtoWnd(CPDFSDK_PageView* pPageView, |
| 115 const CFX_FloatRect& rect); | 113 const CFX_FloatRect& rect); |
| 116 | 114 |
| 117 void SetWindowRect(CPDFSDK_PageView* pPageView, | 115 void SetWindowRect(CPDFSDK_PageView* pPageView, |
| 118 const CFX_FloatRect& rcWindow); | 116 const CFX_FloatRect& rcWindow); |
| 119 CFX_FloatRect GetWindowRect(CPDFSDK_PageView* pPageView); | 117 CFX_FloatRect GetWindowRect(CPDFSDK_PageView* pPageView); |
| 120 | 118 |
| 121 FX_BOOL CommitData(CPDFSDK_PageView* pPageView, uint32_t nFlag); | 119 bool CommitData(CPDFSDK_PageView* pPageView, uint32_t nFlag); |
| 122 virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); | 120 virtual bool IsDataChanged(CPDFSDK_PageView* pPageView); |
| 123 virtual void SaveData(CPDFSDK_PageView* pPageView); | 121 virtual void SaveData(CPDFSDK_PageView* pPageView); |
| 124 | 122 |
| 125 #ifdef PDF_ENABLE_XFA | 123 #ifdef PDF_ENABLE_XFA |
| 126 virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView); | 124 virtual bool IsFieldFull(CPDFSDK_PageView* pPageView); |
| 127 #endif // PDF_ENABLE_XFA | 125 #endif // PDF_ENABLE_XFA |
| 128 | 126 |
| 129 CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); | 127 CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, bool bNew); |
| 130 void DestroyPDFWindow(CPDFSDK_PageView* pPageView); | 128 void DestroyPDFWindow(CPDFSDK_PageView* pPageView); |
| 131 void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); | 129 void EscapeFiller(CPDFSDK_PageView* pPageView, bool bDestroyPDFWindow); |
| 132 | 130 |
| 133 virtual PWL_CREATEPARAM GetCreateParam(); | 131 virtual PWL_CREATEPARAM GetCreateParam(); |
| 134 virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, | 132 virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, |
| 135 CPDFSDK_PageView* pPageView) = 0; | 133 CPDFSDK_PageView* pPageView) = 0; |
| 136 virtual CFX_FloatRect GetFocusBox(CPDFSDK_PageView* pPageView); | 134 virtual CFX_FloatRect GetFocusBox(CPDFSDK_PageView* pPageView); |
| 137 | 135 |
| 138 FX_BOOL IsValid() const; | 136 bool IsValid() const; |
| 139 CFX_FloatRect GetPDFWindowRect() const; | 137 CFX_FloatRect GetPDFWindowRect() const; |
| 140 | 138 |
| 141 CPDFSDK_PageView* GetCurPageView(bool renew); | 139 CPDFSDK_PageView* GetCurPageView(bool renew); |
| 142 void SetChangeMark(); | 140 void SetChangeMark(); |
| 143 | 141 |
| 144 virtual void InvalidateRect(double left, | 142 virtual void InvalidateRect(double left, |
| 145 double top, | 143 double top, |
| 146 double right, | 144 double right, |
| 147 double bottom); | 145 double bottom); |
| 148 CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; } | 146 CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; } |
| 149 | 147 |
| 150 protected: | 148 protected: |
| 151 using CFFL_PageView2PDFWindow = std::map<CPDFSDK_PageView*, CPWL_Wnd*>; | 149 using CFFL_PageView2PDFWindow = std::map<CPDFSDK_PageView*, CPWL_Wnd*>; |
| 152 | 150 |
| 153 // If the inheriting widget has its own fontmap and a PWL_Edit widget that | 151 // If the inheriting widget has its own fontmap and a PWL_Edit widget that |
| 154 // access that fontmap then you have to call DestroyWindows before destroying | 152 // access that fontmap then you have to call DestroyWindows before destroying |
| 155 // the font map in order to not get a use-after-free. | 153 // the font map in order to not get a use-after-free. |
| 156 // | 154 // |
| 157 // The font map should be stored somewhere more appropriate so it will live | 155 // The font map should be stored somewhere more appropriate so it will live |
| 158 // until the PWL_Edit is done with it. pdfium:566 | 156 // until the PWL_Edit is done with it. pdfium:566 |
| 159 void DestroyWindows(); | 157 void DestroyWindows(); |
| 160 | 158 |
| 161 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; | 159 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; |
| 162 CPDFSDK_Widget* m_pWidget; | 160 CPDFSDK_Widget* m_pWidget; |
| 163 CPDFSDK_Annot* m_pAnnot; | 161 CPDFSDK_Annot* m_pAnnot; |
| 164 | 162 |
| 165 FX_BOOL m_bValid; | 163 bool m_bValid; |
| 166 CFFL_PageView2PDFWindow m_Maps; | 164 CFFL_PageView2PDFWindow m_Maps; |
| 167 CFX_FloatPoint m_ptOldPos; | 165 CFX_FloatPoint m_ptOldPos; |
| 168 }; | 166 }; |
| 169 | 167 |
| 170 class CFFL_Button : public CFFL_FormFiller { | 168 class CFFL_Button : public CFFL_FormFiller { |
| 171 public: | 169 public: |
| 172 CFFL_Button(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 170 CFFL_Button(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 173 CPDFSDK_Annot* pWidget); | 171 CPDFSDK_Annot* pWidget); |
| 174 ~CFFL_Button() override; | 172 ~CFFL_Button() override; |
| 175 | 173 |
| 176 // CFFL_FormFiller | 174 // CFFL_FormFiller |
| 177 void OnMouseEnter(CPDFSDK_PageView* pPageView, | 175 void OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 178 CPDFSDK_Annot* pAnnot) override; | 176 CPDFSDK_Annot* pAnnot) override; |
| 179 void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) override; | 177 void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) override; |
| 180 FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, | 178 bool OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 181 CPDFSDK_Annot* pAnnot, | 179 CPDFSDK_Annot* pAnnot, |
| 182 uint32_t nFlags, | 180 uint32_t nFlags, |
| 183 const CFX_FloatPoint& point) override; | 181 const CFX_FloatPoint& point) override; |
| 184 FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, | 182 bool OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 185 CPDFSDK_Annot* pAnnot, | 183 CPDFSDK_Annot* pAnnot, |
| 186 uint32_t nFlags, | 184 uint32_t nFlags, |
| 187 const CFX_FloatPoint& point) override; | 185 const CFX_FloatPoint& point) override; |
| 188 FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, | 186 bool OnMouseMove(CPDFSDK_PageView* pPageView, |
| 189 CPDFSDK_Annot* pAnnot, | 187 CPDFSDK_Annot* pAnnot, |
| 190 uint32_t nFlags, | 188 uint32_t nFlags, |
| 191 const CFX_FloatPoint& point) override; | 189 const CFX_FloatPoint& point) override; |
| 192 void OnDraw(CPDFSDK_PageView* pPageView, | 190 void OnDraw(CPDFSDK_PageView* pPageView, |
| 193 CPDFSDK_Annot* pAnnot, | 191 CPDFSDK_Annot* pAnnot, |
| 194 CFX_RenderDevice* pDevice, | 192 CFX_RenderDevice* pDevice, |
| 195 CFX_Matrix* pUser2Device) override; | 193 CFX_Matrix* pUser2Device) override; |
| 196 void OnDrawDeactive(CPDFSDK_PageView* pPageView, | 194 void OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 197 CPDFSDK_Annot* pAnnot, | 195 CPDFSDK_Annot* pAnnot, |
| 198 CFX_RenderDevice* pDevice, | 196 CFX_RenderDevice* pDevice, |
| 199 CFX_Matrix* pUser2Device) override; | 197 CFX_Matrix* pUser2Device) override; |
| 200 | 198 |
| 201 protected: | 199 protected: |
| 202 FX_BOOL m_bMouseIn; | 200 bool m_bMouseIn; |
| 203 FX_BOOL m_bMouseDown; | 201 bool m_bMouseDown; |
| 204 }; | 202 }; |
| 205 | 203 |
| 206 #endif // FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ | 204 #endif // FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ |
| OLD | NEW |