1 // Copyright 2016 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_FPDFXFA_CPDFXFA_WIDGETHANDLER_H_ 8 #define FPDFSDK_FPDFXFA_CPDFXFA_WIDGETHANDLER_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/unowned_ptr.h" 14 #include "fpdfsdk/ipdfsdk_annothandler.h" 15 16 class CFX_Matrix; 17 class CFX_RenderDevice; 18 class CPDF_Annot; 19 class CPDFSDK_FormFillEnvironment; 20 class CPDFSDK_Annot; 21 class CPDFSDK_PageView; 22 class CXFA_FFWidget; 23 class CXFA_FFWidgetHandler; 24 25 class CPDFXFA_WidgetHandler final : public IPDFSDK_AnnotHandler { 26 public: 27 CPDFXFA_WidgetHandler(); 28 ~CPDFXFA_WidgetHandler() override; 29 30 // IPDFSDK_AnnotHandler: 31 void SetFormFillEnvironment( 32 CPDFSDK_FormFillEnvironment* pFormFillEnv) override; 33 bool CanAnswer(CPDFSDK_Annot* pAnnot) override; 34 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; 35 void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) override; 36 CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, 37 CPDFSDK_Annot* pAnnot) override; 38 WideString GetText(CPDFSDK_Annot* pAnnot) override; 39 WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override; 40 void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override; 41 bool CanUndo(CPDFSDK_Annot* pAnnot) override; 42 bool CanRedo(CPDFSDK_Annot* pAnnot) override; 43 bool Undo(CPDFSDK_Annot* pAnnot) override; 44 bool Redo(CPDFSDK_Annot* pAnnot) override; 45 bool HitTest(CPDFSDK_PageView* pPageView, 46 CPDFSDK_Annot* pAnnot, 47 const CFX_PointF& point) override; 48 void OnDraw(CPDFSDK_PageView* pPageView, 49 CPDFSDK_Annot* pAnnot, 50 CFX_RenderDevice* pDevice, 51 const CFX_Matrix& mtUser2Device, 52 bool bDrawAnnots) override; 53 void OnLoad(CPDFSDK_Annot* pAnnot) override; 54 void OnMouseEnter(CPDFSDK_PageView* pPageView, 55 ObservedPtr<CPDFSDK_Annot>* pAnnot, 56 uint32_t nFlag) override; 57 void OnMouseExit(CPDFSDK_PageView* pPageView, 58 ObservedPtr<CPDFSDK_Annot>* pAnnot, 59 uint32_t nFlag) override; 60 bool OnLButtonDown(CPDFSDK_PageView* pPageView, 61 ObservedPtr<CPDFSDK_Annot>* pAnnot, 62 uint32_t nFlags, 63 const CFX_PointF& point) override; 64 bool OnLButtonUp(CPDFSDK_PageView* pPageView, 65 ObservedPtr<CPDFSDK_Annot>* pAnnot, 66 uint32_t nFlags, 67 const CFX_PointF& point) override; 68 bool OnLButtonDblClk(CPDFSDK_PageView* pPageView, 69 ObservedPtr<CPDFSDK_Annot>* pAnnot, 70 uint32_t nFlags, 71 const CFX_PointF& point) override; 72 bool OnMouseMove(CPDFSDK_PageView* pPageView, 73 ObservedPtr<CPDFSDK_Annot>* pAnnot, 74 uint32_t nFlags, 75 const CFX_PointF& point) override; 76 bool OnMouseWheel(CPDFSDK_PageView* pPageView, 77 ObservedPtr<CPDFSDK_Annot>* pAnnot, 78 uint32_t nFlags, 79 short zDelta, 80 const CFX_PointF& point) override; 81 bool OnRButtonDown(CPDFSDK_PageView* pPageView, 82 ObservedPtr<CPDFSDK_Annot>* pAnnot, 83 uint32_t nFlags, 84 const CFX_PointF& point) override; 85 bool OnRButtonUp(CPDFSDK_PageView* pPageView, 86 ObservedPtr<CPDFSDK_Annot>* pAnnot, 87 uint32_t nFlags, 88 const CFX_PointF& point) override; 89 bool OnRButtonDblClk(CPDFSDK_PageView* pPageView, 90 ObservedPtr<CPDFSDK_Annot>* pAnnot, 91 uint32_t nFlags, 92 const CFX_PointF& point) override; 93 bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override; 94 bool OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; 95 bool OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; 96 bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override; 97 bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override; 98 bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, 99 int index, 100 bool selected) override; 101 bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, int index) override; 102 103 std::unique_ptr<CPDFSDK_Annot> NewAnnotForXFA(CXFA_FFWidget* pAnnot, 104 CPDFSDK_PageView* pPage); 105 bool OnXFAChangedFocus(ObservedPtr<CPDFSDK_Annot>* pOldAnnot, 106 ObservedPtr<CPDFSDK_Annot>* pNewAnnot); 107 108 private: 109 CXFA_FFWidgetHandler* GetXFAFFWidgetHandler(CPDFSDK_Annot* pAnnot); 110 uint32_t GetFWLFlags(uint32_t dwFlag); 111 112 UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv; 113 }; 114 115 #endif // FPDFSDK_FPDFXFA_CPDFXFA_WIDGETHANDLER_H_ 116