| 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_INTERACTIVEFORMFILLER_H_ | 7 #ifndef FPDFSDK_FORMFILLER_CFFL_INTERACTIVEFORMFILLER_H_ |
| 8 #define FPDFSDK_FORMFILLER_CFFL_INTERACTIVEFORMFILLER_H_ | 8 #define FPDFSDK_FORMFILLER_CFFL_INTERACTIVEFORMFILLER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "fpdfsdk/cpdfsdk_annot.h" | 13 #include "fpdfsdk/cpdfsdk_annot.h" |
| 14 #include "fpdfsdk/fsdk_define.h" | 14 #include "fpdfsdk/fsdk_define.h" |
| 15 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 15 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 16 | 16 |
| 17 class CFFL_FormFiller; | 17 class CFFL_FormFiller; |
| 18 class CPDFSDK_FormFillEnvironment; | 18 class CPDFSDK_FormFillEnvironment; |
| 19 class CPDFSDK_PageView; | 19 class CPDFSDK_PageView; |
| 20 class CPDFSDK_Widget; | 20 class CPDFSDK_Widget; |
| 21 | 21 |
| 22 class CFFL_InteractiveFormFiller : public IPWL_Filler_Notify { | 22 class CFFL_InteractiveFormFiller : public IPWL_Filler_Notify { |
| 23 public: | 23 public: |
| 24 explicit CFFL_InteractiveFormFiller( | 24 explicit CFFL_InteractiveFormFiller( |
| 25 CPDFSDK_FormFillEnvironment* pFormFillEnv); | 25 CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 26 ~CFFL_InteractiveFormFiller() override; | 26 ~CFFL_InteractiveFormFiller() override; |
| 27 | 27 |
| 28 FX_BOOL Annot_HitTest(CPDFSDK_PageView* pPageView, | 28 bool Annot_HitTest(CPDFSDK_PageView* pPageView, |
| 29 CPDFSDK_Annot* pAnnot, | 29 CPDFSDK_Annot* pAnnot, |
| 30 CFX_FloatPoint point); | 30 CFX_FloatPoint point); |
| 31 FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); | 31 FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); |
| 32 void OnDraw(CPDFSDK_PageView* pPageView, | 32 void OnDraw(CPDFSDK_PageView* pPageView, |
| 33 CPDFSDK_Annot* pAnnot, | 33 CPDFSDK_Annot* pAnnot, |
| 34 CFX_RenderDevice* pDevice, | 34 CFX_RenderDevice* pDevice, |
| 35 CFX_Matrix* pUser2Device); | 35 CFX_Matrix* pUser2Device); |
| 36 | 36 |
| 37 void OnDelete(CPDFSDK_Annot* pAnnot); | 37 void OnDelete(CPDFSDK_Annot* pAnnot); |
| 38 | 38 |
| 39 void OnMouseEnter(CPDFSDK_PageView* pPageView, | 39 void OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 40 CPDFSDK_Annot::ObservedPtr* pAnnot, | 40 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 41 uint32_t nFlag); | 41 uint32_t nFlag); |
| 42 void OnMouseExit(CPDFSDK_PageView* pPageView, | 42 void OnMouseExit(CPDFSDK_PageView* pPageView, |
| 43 CPDFSDK_Annot::ObservedPtr* pAnnot, | 43 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 44 uint32_t nFlag); | 44 uint32_t nFlag); |
| 45 FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, | 45 bool OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 46 CPDFSDK_Annot::ObservedPtr* pAnnot, | 46 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 47 uint32_t nFlags, | 47 uint32_t nFlags, |
| 48 const CFX_FloatPoint& point); | 48 const CFX_FloatPoint& point); |
| 49 FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, | 49 bool OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 50 CPDFSDK_Annot::ObservedPtr* pAnnot, | 50 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 51 uint32_t nFlags, | 51 uint32_t nFlags, |
| 52 const CFX_FloatPoint& point); | 52 const CFX_FloatPoint& point); |
| 53 FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 53 bool OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 54 CPDFSDK_Annot::ObservedPtr* pAnnot, | |
| 55 uint32_t nFlags, | |
| 56 const CFX_FloatPoint& point); | |
| 57 FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, | |
| 58 CPDFSDK_Annot::ObservedPtr* pAnnot, | |
| 59 uint32_t nFlags, | |
| 60 const CFX_FloatPoint& point); | |
| 61 FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, | |
| 62 CPDFSDK_Annot::ObservedPtr* pAnnot, | 54 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 63 uint32_t nFlags, | 55 uint32_t nFlags, |
| 64 short zDelta, | |
| 65 const CFX_FloatPoint& point); | 56 const CFX_FloatPoint& point); |
| 66 FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, | 57 bool OnMouseMove(CPDFSDK_PageView* pPageView, |
| 67 CPDFSDK_Annot::ObservedPtr* pAnnot, | 58 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 68 uint32_t nFlags, | 59 uint32_t nFlags, |
| 69 const CFX_FloatPoint& point); | 60 const CFX_FloatPoint& point); |
| 70 FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, | 61 bool OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 71 CPDFSDK_Annot::ObservedPtr* pAnnot, | 62 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 72 uint32_t nFlags, | 63 uint32_t nFlags, |
| 73 const CFX_FloatPoint& point); | 64 short zDelta, |
| 65 const CFX_FloatPoint& point); |
| 66 bool OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 67 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 68 uint32_t nFlags, |
| 69 const CFX_FloatPoint& point); |
| 70 bool OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 71 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 72 uint32_t nFlags, |
| 73 const CFX_FloatPoint& point); |
| 74 | 74 |
| 75 FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, uint32_t nKeyCode, uint32_t nFlags); | 75 bool OnKeyDown(CPDFSDK_Annot* pAnnot, uint32_t nKeyCode, uint32_t nFlags); |
| 76 FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags); | 76 bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags); |
| 77 | 77 |
| 78 FX_BOOL OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); | 78 bool OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); |
| 79 FX_BOOL OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); | 79 bool OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); |
| 80 | 80 |
| 81 CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister); | 81 CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot, bool bRegister); |
| 82 void RemoveFormFiller(CPDFSDK_Annot* pAnnot); | 82 void RemoveFormFiller(CPDFSDK_Annot* pAnnot); |
| 83 | 83 |
| 84 static FX_BOOL IsVisible(CPDFSDK_Widget* pWidget); | 84 static bool IsVisible(CPDFSDK_Widget* pWidget); |
| 85 static FX_BOOL IsReadOnly(CPDFSDK_Widget* pWidget); | 85 static bool IsReadOnly(CPDFSDK_Widget* pWidget); |
| 86 static FX_BOOL IsFillingAllowed(CPDFSDK_Widget* pWidget); | 86 static bool IsFillingAllowed(CPDFSDK_Widget* pWidget); |
| 87 static FX_BOOL IsValidAnnot(CPDFSDK_PageView* pPageView, | 87 static bool IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); |
| 88 CPDFSDK_Annot* pAnnot); | |
| 89 | 88 |
| 90 void OnKeyStrokeCommit(CPDFSDK_Annot::ObservedPtr* pWidget, | 89 void OnKeyStrokeCommit(CPDFSDK_Annot::ObservedPtr* pWidget, |
| 91 CPDFSDK_PageView* pPageView, | 90 CPDFSDK_PageView* pPageView, |
| 92 FX_BOOL& bRC, | 91 bool& bRC, |
| 93 FX_BOOL& bExit, | 92 bool& bExit, |
| 94 uint32_t nFlag); | 93 uint32_t nFlag); |
| 95 void OnValidate(CPDFSDK_Annot::ObservedPtr* pWidget, | 94 void OnValidate(CPDFSDK_Annot::ObservedPtr* pWidget, |
| 96 CPDFSDK_PageView* pPageView, | 95 CPDFSDK_PageView* pPageView, |
| 97 FX_BOOL& bRC, | 96 bool& bRC, |
| 98 FX_BOOL& bExit, | 97 bool& bExit, |
| 99 uint32_t nFlag); | 98 uint32_t nFlag); |
| 100 | 99 |
| 101 void OnCalculate(CPDFSDK_Widget* pWidget, | 100 void OnCalculate(CPDFSDK_Widget* pWidget, |
| 102 CPDFSDK_PageView* pPageView, | 101 CPDFSDK_PageView* pPageView, |
| 103 FX_BOOL& bExit, | 102 bool& bExit, |
| 104 uint32_t nFlag); | 103 uint32_t nFlag); |
| 105 void OnFormat(CPDFSDK_Widget* pWidget, | 104 void OnFormat(CPDFSDK_Widget* pWidget, |
| 106 CPDFSDK_PageView* pPageView, | 105 CPDFSDK_PageView* pPageView, |
| 107 FX_BOOL& bExit, | 106 bool& bExit, |
| 108 uint32_t nFlag); | 107 uint32_t nFlag); |
| 109 void OnButtonUp(CPDFSDK_Annot::ObservedPtr* pWidget, | 108 void OnButtonUp(CPDFSDK_Annot::ObservedPtr* pWidget, |
| 110 CPDFSDK_PageView* pPageView, | 109 CPDFSDK_PageView* pPageView, |
| 111 FX_BOOL& bReset, | 110 bool& bReset, |
| 112 FX_BOOL& bExit, | 111 bool& bExit, |
| 113 uint32_t nFlag); | 112 uint32_t nFlag); |
| 114 #ifdef PDF_ENABLE_XFA | 113 #ifdef PDF_ENABLE_XFA |
| 115 void OnClick(CPDFSDK_Widget* pWidget, | 114 void OnClick(CPDFSDK_Widget* pWidget, |
| 116 CPDFSDK_PageView* pPageView, | 115 CPDFSDK_PageView* pPageView, |
| 117 FX_BOOL& bReset, | 116 bool& bReset, |
| 118 FX_BOOL& bExit, | 117 bool& bExit, |
| 119 uint32_t nFlag); | 118 uint32_t nFlag); |
| 120 void OnFull(CPDFSDK_Widget* pWidget, | 119 void OnFull(CPDFSDK_Widget* pWidget, |
| 121 CPDFSDK_PageView* pPageView, | 120 CPDFSDK_PageView* pPageView, |
| 122 FX_BOOL& bReset, | 121 bool& bReset, |
| 123 FX_BOOL& bExit, | 122 bool& bExit, |
| 124 uint32_t nFlag); | 123 uint32_t nFlag); |
| 125 void OnPreOpen(CPDFSDK_Widget* pWidget, | 124 void OnPreOpen(CPDFSDK_Widget* pWidget, |
| 126 CPDFSDK_PageView* pPageView, | 125 CPDFSDK_PageView* pPageView, |
| 127 FX_BOOL& bReset, | 126 bool& bReset, |
| 128 FX_BOOL& bExit, | 127 bool& bExit, |
| 129 uint32_t nFlag); | 128 uint32_t nFlag); |
| 130 void OnPostOpen(CPDFSDK_Widget* pWidget, | 129 void OnPostOpen(CPDFSDK_Widget* pWidget, |
| 131 CPDFSDK_PageView* pPageView, | 130 CPDFSDK_PageView* pPageView, |
| 132 FX_BOOL& bReset, | 131 bool& bReset, |
| 133 FX_BOOL& bExit, | 132 bool& bExit, |
| 134 uint32_t nFlag); | 133 uint32_t nFlag); |
| 135 #endif // PDF_ENABLE_XFA | 134 #endif // PDF_ENABLE_XFA |
| 136 | 135 |
| 137 private: | 136 private: |
| 138 using CFFL_Widget2Filler = | 137 using CFFL_Widget2Filler = |
| 139 std::map<CPDFSDK_Annot*, std::unique_ptr<CFFL_FormFiller>>; | 138 std::map<CPDFSDK_Annot*, std::unique_ptr<CFFL_FormFiller>>; |
| 140 | 139 |
| 141 // IPWL_Filler_Notify: | 140 // IPWL_Filler_Notify: |
| 142 void QueryWherePopup(void* pPrivateData, | 141 void QueryWherePopup(void* pPrivateData, |
| 143 FX_FLOAT fPopupMin, | 142 FX_FLOAT fPopupMin, |
| 144 FX_FLOAT fPopupMax, | 143 FX_FLOAT fPopupMax, |
| 145 int32_t& nRet, | 144 int32_t& nRet, |
| 146 FX_FLOAT& fPopupRet) override; | 145 FX_FLOAT& fPopupRet) override; |
| 147 void OnBeforeKeyStroke(void* pPrivateData, | 146 void OnBeforeKeyStroke(void* pPrivateData, |
| 148 CFX_WideString& strChange, | 147 CFX_WideString& strChange, |
| 149 const CFX_WideString& strChangeEx, | 148 const CFX_WideString& strChangeEx, |
| 150 int nSelStart, | 149 int nSelStart, |
| 151 int nSelEnd, | 150 int nSelEnd, |
| 152 FX_BOOL bKeyDown, | 151 bool bKeyDown, |
| 153 FX_BOOL& bRC, | 152 bool& bRC, |
| 154 FX_BOOL& bExit, | 153 bool& bExit, |
| 155 uint32_t nFlag) override; | 154 uint32_t nFlag) override; |
| 156 #ifdef PDF_ENABLE_XFA | 155 #ifdef PDF_ENABLE_XFA |
| 157 void OnPopupPreOpen(void* pPrivateData, | 156 void OnPopupPreOpen(void* pPrivateData, bool& bExit, uint32_t nFlag) override; |
| 158 FX_BOOL& bExit, | |
| 159 uint32_t nFlag) override; | |
| 160 void OnPopupPostOpen(void* pPrivateData, | 157 void OnPopupPostOpen(void* pPrivateData, |
| 161 FX_BOOL& bExit, | 158 bool& bExit, |
| 162 uint32_t nFlag) override; | 159 uint32_t nFlag) override; |
| 163 void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, | 160 void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, bool bSameField, bool bNext); |
| 164 FX_BOOL bSameField, | |
| 165 FX_BOOL bNext); | |
| 166 #endif // PDF_ENABLE_XFA | 161 #endif // PDF_ENABLE_XFA |
| 167 void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); | 162 void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); |
| 168 | 163 |
| 169 CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; | 164 CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; |
| 170 CFFL_Widget2Filler m_Maps; | 165 CFFL_Widget2Filler m_Maps; |
| 171 FX_BOOL m_bNotifying; | 166 bool m_bNotifying; |
| 172 }; | 167 }; |
| 173 | 168 |
| 174 class CFFL_PrivateData { | 169 class CFFL_PrivateData { |
| 175 public: | 170 public: |
| 176 CPDFSDK_Widget* pWidget; | 171 CPDFSDK_Widget* pWidget; |
| 177 CPDFSDK_PageView* pPageView; | 172 CPDFSDK_PageView* pPageView; |
| 178 int nWidgetAge; | 173 int nWidgetAge; |
| 179 int nValueAge; | 174 int nValueAge; |
| 180 }; | 175 }; |
| 181 | 176 |
| 182 #endif // FPDFSDK_FORMFILLER_CFFL_INTERACTIVEFORMFILLER_H_ | 177 #endif // FPDFSDK_FORMFILLER_CFFL_INTERACTIVEFORMFILLER_H_ |
| OLD | NEW |