jaepark | 98e1019 | 2016-08-15 10:51:11 -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 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_ |
| 8 | #define FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_ |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 9 | |
| 10 | #include <map> |
| 11 | #include <memory> |
| 12 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 13 | #include "core/fpdfdoc/cpdf_annot.h" |
Tom Sepez | 940967d | 2017-05-18 12:32:20 -0700 | [diff] [blame] | 14 | #include "core/fxcrt/cfx_unowned_ptr.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 15 | #include "core/fxcrt/fx_basic.h" |
| 16 | #include "core/fxcrt/fx_coordinates.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 17 | #include "fpdfsdk/cpdfsdk_annot.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 18 | |
| 19 | class CFX_Matrix; |
| 20 | class CFX_RenderDevice; |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 21 | class CPDFSDK_FormFillEnvironment; |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 22 | class CPDFSDK_BAAnnotHandler; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 23 | class CPDFSDK_WidgetHandler; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 24 | class CPDFSDK_PageView; |
| 25 | class IPDFSDK_AnnotHandler; |
| 26 | |
| 27 | #ifdef PDF_ENABLE_XFA |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 28 | class CPDFSDK_XFAWidgetHandler; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 29 | class CXFA_FFWidget; |
| 30 | #endif // PDF_ENABLE_XFA |
| 31 | |
| 32 | class CPDFSDK_AnnotHandlerMgr { |
| 33 | public: |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 34 | explicit CPDFSDK_AnnotHandlerMgr(CPDFSDK_FormFillEnvironment* pApp); |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 35 | ~CPDFSDK_AnnotHandlerMgr(); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 36 | |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 37 | CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 38 | #ifdef PDF_ENABLE_XFA |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 39 | CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPageView); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 40 | #endif // PDF_ENABLE_XFA |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 41 | void ReleaseAnnot(CPDFSDK_Annot* pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 42 | |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 43 | void Annot_OnCreate(CPDFSDK_Annot* pAnnot); |
| 44 | void Annot_OnLoad(CPDFSDK_Annot* pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 45 | |
Diana Gage | dce2d72 | 2017-06-20 11:17:11 -0700 | [diff] [blame] | 46 | CFX_WideString Annot_GetSelectedText(CPDFSDK_Annot* pAnnot); |
| 47 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 48 | IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 49 | void Annot_OnDraw(CPDFSDK_PageView* pPageView, |
| 50 | CPDFSDK_Annot* pAnnot, |
| 51 | CFX_RenderDevice* pDevice, |
| 52 | CFX_Matrix* pUser2Device, |
| 53 | bool bDrawAnnots); |
| 54 | |
| 55 | void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 56 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 57 | uint32_t nFlags); |
| 58 | void Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 59 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 60 | uint32_t nFlags); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 61 | bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 62 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 63 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 64 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 65 | bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 66 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 67 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 68 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 69 | bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 70 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 71 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 72 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 73 | bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView, |
| 74 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 75 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 76 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 77 | bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 78 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 79 | uint32_t nFlags, |
| 80 | short zDelta, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 81 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 82 | bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 83 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 84 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 85 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 86 | bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 87 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 88 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 89 | const CFX_PointF& point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 90 | bool Annot_OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags); |
| 91 | bool Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); |
| 92 | bool Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 93 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 94 | bool Annot_OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); |
| 95 | bool Annot_OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 96 | |
| 97 | #ifdef PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 98 | bool Annot_OnChangeFocus(CPDFSDK_Annot::ObservedPtr* pSetAnnot, |
| 99 | CPDFSDK_Annot::ObservedPtr* pKillAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 100 | #endif // PDF_ENABLE_XFA |
| 101 | |
tsepez | 9c33e89 | 2016-09-26 12:29:20 -0700 | [diff] [blame] | 102 | CFX_FloatRect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, |
| 103 | CPDFSDK_Annot* pAnnot); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 104 | bool Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 105 | CPDFSDK_Annot* pAnnot, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 106 | const CFX_PointF& point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 107 | |
| 108 | private: |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 109 | IPDFSDK_AnnotHandler* GetAnnotHandler(CPDF_Annot::Subtype nSubtype) const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 110 | CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, bool bNext); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 111 | |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 112 | std::unique_ptr<CPDFSDK_BAAnnotHandler> m_pBAAnnotHandler; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 113 | std::unique_ptr<CPDFSDK_WidgetHandler> m_pWidgetHandler; |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 114 | #ifdef PDF_ENABLE_XFA |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 115 | std::unique_ptr<CPDFSDK_XFAWidgetHandler> m_pXFAWidgetHandler; |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 116 | #endif // PDF_ENABLE_XFA |
| 117 | |
Tom Sepez | 940967d | 2017-05-18 12:32:20 -0700 | [diff] [blame] | 118 | CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 121 | #endif // FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_ |