Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 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_CPDFSDK_ANNOTHANDLERMGR_H_ |
| 8 | #define FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_ |
| 9 | |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
| 12 | #include "core/fpdfdoc/cpdf_annot.h" |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 13 | #include "core/fxcrt/fx_coordinates.h" |
| 14 | #include "fpdfsdk/cpdfsdk_annot.h" |
| 15 | |
| 16 | class CFX_Matrix; |
| 17 | class CFX_RenderDevice; |
| 18 | class CPDFSDK_FormFillEnvironment; |
| 19 | class CPDFSDK_BAAnnotHandler; |
| 20 | class CPDFSDK_WidgetHandler; |
| 21 | class CPDFSDK_PageView; |
| 22 | class IPDFSDK_AnnotHandler; |
| 23 | |
| 24 | #ifdef PDF_ENABLE_XFA |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 25 | class CXFA_FFWidget; |
| 26 | #endif // PDF_ENABLE_XFA |
| 27 | |
| 28 | class CPDFSDK_AnnotHandlerMgr { |
| 29 | public: |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 30 | CPDFSDK_AnnotHandlerMgr( |
| 31 | std::unique_ptr<CPDFSDK_BAAnnotHandler> pBAAnnotHandler, |
| 32 | std::unique_ptr<CPDFSDK_WidgetHandler> pWidgetHandler, |
| 33 | std::unique_ptr<IPDFSDK_AnnotHandler> pXFAWidgetHandler); |
| 34 | |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 35 | ~CPDFSDK_AnnotHandlerMgr(); |
| 36 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 37 | void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 38 | |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 39 | CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); |
| 40 | #ifdef PDF_ENABLE_XFA |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 41 | std::unique_ptr<CPDFSDK_Annot> NewXFAAnnot(CXFA_FFWidget* pAnnot, |
| 42 | CPDFSDK_PageView* pPageView); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 43 | #endif // PDF_ENABLE_XFA |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 44 | void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 45 | |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 46 | void Annot_OnLoad(CPDFSDK_Annot* pAnnot); |
| 47 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 48 | WideString Annot_GetText(CPDFSDK_Annot* pAnnot); |
Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 49 | WideString Annot_GetSelectedText(CPDFSDK_Annot* pAnnot); |
| 50 | void Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text); |
| 51 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 52 | bool Annot_CanUndo(CPDFSDK_Annot* pAnnot); |
| 53 | bool Annot_CanRedo(CPDFSDK_Annot* pAnnot); |
| 54 | bool Annot_Undo(CPDFSDK_Annot* pAnnot); |
| 55 | bool Annot_Redo(CPDFSDK_Annot* pAnnot); |
| 56 | |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 57 | void Annot_OnDraw(CPDFSDK_PageView* pPageView, |
| 58 | CPDFSDK_Annot* pAnnot, |
| 59 | CFX_RenderDevice* pDevice, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 60 | const CFX_Matrix& mtUser2Device, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 61 | bool bDrawAnnots); |
| 62 | |
| 63 | void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 64 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 65 | uint32_t nFlags); |
| 66 | void Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 67 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 68 | uint32_t nFlags); |
| 69 | bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 70 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 71 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 72 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 73 | bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 74 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 75 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 76 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 77 | bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 78 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 79 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 80 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 81 | bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 82 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 83 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 84 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 85 | bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 86 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 87 | uint32_t nFlags, |
| 88 | short zDelta, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 89 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 90 | bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 91 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 92 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 93 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 94 | bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView, |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 95 | ObservedPtr<CPDFSDK_Annot>* pAnnot, |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 96 | uint32_t nFlags, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 97 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 98 | bool Annot_OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags); |
| 99 | bool Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 100 | bool Annot_OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag); |
| 101 | bool Annot_OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag); |
| 102 | bool Annot_SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, |
| 103 | int index, |
| 104 | bool selected); |
| 105 | bool Annot_IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, int index); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 106 | |
| 107 | #ifdef PDF_ENABLE_XFA |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 108 | bool Annot_OnChangeFocus(ObservedPtr<CPDFSDK_Annot>* pSetAnnot, |
| 109 | ObservedPtr<CPDFSDK_Annot>* pKillAnnot); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 110 | #endif // PDF_ENABLE_XFA |
| 111 | |
| 112 | CFX_FloatRect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, |
| 113 | CPDFSDK_Annot* pAnnot); |
| 114 | bool Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 115 | CPDFSDK_Annot* pAnnot, |
Philip P. Moltmann | 33357ca | 2017-05-11 09:25:13 -0700 | [diff] [blame] | 116 | const CFX_PointF& point); |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 117 | |
| 118 | private: |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 119 | friend class CPDFSDK_BAAnnotHandlerTest; |
| 120 | |
| 121 | IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; |
| 122 | IPDFSDK_AnnotHandler* GetAnnotHandlerOfType( |
| 123 | CPDF_Annot::Subtype nAnnotSubtype) const; |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 124 | CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, bool bNext); |
| 125 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 126 | // |m_pBAAnnotHandler| and |m_pWidgetHandler| are always present, but |
| 127 | // |m_pXFAWidgetHandler| is only present in XFA mode. |
| 128 | std::unique_ptr<CPDFSDK_BAAnnotHandler> const m_pBAAnnotHandler; |
| 129 | std::unique_ptr<CPDFSDK_WidgetHandler> const m_pWidgetHandler; |
| 130 | std::unique_ptr<IPDFSDK_AnnotHandler> const m_pXFAWidgetHandler; |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | #endif // FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_ |