blob: df4e1a224c013c0b45925b0e25f5b7e7d774a015 [file] [log] [blame]
jaepark98e10192016-08-15 10:51:11 -07001// 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
dsinclair114e46a2016-09-29 17:18:21 -07007#ifndef FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_
8#define FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_
jaepark98e10192016-08-15 10:51:11 -07009
10#include <map>
11#include <memory>
12
dsinclair1727aee2016-09-29 13:12:56 -070013#include "core/fpdfdoc/cpdf_annot.h"
dsinclaira52ab742016-09-29 13:59:29 -070014#include "core/fxcrt/fx_coordinates.h"
Dan Sinclairaee0db02017-09-21 16:53:58 -040015#include "core/fxcrt/unowned_ptr.h"
dsinclair114e46a2016-09-29 17:18:21 -070016#include "fpdfsdk/cpdfsdk_annot.h"
jaepark98e10192016-08-15 10:51:11 -070017
18class CFX_Matrix;
19class CFX_RenderDevice;
dsinclair735606d2016-10-05 15:47:02 -070020class CPDFSDK_FormFillEnvironment;
jaepark35512aa2016-08-29 17:15:08 -070021class CPDFSDK_BAAnnotHandler;
jaepark8c541822016-08-30 13:43:05 -070022class CPDFSDK_WidgetHandler;
jaepark98e10192016-08-15 10:51:11 -070023class CPDFSDK_PageView;
24class IPDFSDK_AnnotHandler;
25
26#ifdef PDF_ENABLE_XFA
jaepark8c541822016-08-30 13:43:05 -070027class CPDFSDK_XFAWidgetHandler;
jaepark98e10192016-08-15 10:51:11 -070028class CXFA_FFWidget;
29#endif // PDF_ENABLE_XFA
30
31class CPDFSDK_AnnotHandlerMgr {
32 public:
dsinclair735606d2016-10-05 15:47:02 -070033 explicit CPDFSDK_AnnotHandlerMgr(CPDFSDK_FormFillEnvironment* pApp);
tsepez9c33e892016-09-26 12:29:20 -070034 ~CPDFSDK_AnnotHandlerMgr();
jaepark98e10192016-08-15 10:51:11 -070035
tsepez9c33e892016-09-26 12:29:20 -070036 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
jaepark98e10192016-08-15 10:51:11 -070037#ifdef PDF_ENABLE_XFA
tsepez9c33e892016-09-26 12:29:20 -070038 CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPageView);
jaepark98e10192016-08-15 10:51:11 -070039#endif // PDF_ENABLE_XFA
tsepez9c33e892016-09-26 12:29:20 -070040 void ReleaseAnnot(CPDFSDK_Annot* pAnnot);
jaepark98e10192016-08-15 10:51:11 -070041
tsepez9c33e892016-09-26 12:29:20 -070042 void Annot_OnCreate(CPDFSDK_Annot* pAnnot);
43 void Annot_OnLoad(CPDFSDK_Annot* pAnnot);
jaepark98e10192016-08-15 10:51:11 -070044
Ryan Harrison275e2602017-09-18 14:23:18 -040045 WideString Annot_GetSelectedText(CPDFSDK_Annot* pAnnot);
46 void Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text);
Diana Gagedce2d722017-06-20 11:17:11 -070047
jaepark98e10192016-08-15 10:51:11 -070048 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const;
tsepez9c33e892016-09-26 12:29:20 -070049 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,
tsepezf8074ce2016-09-27 14:29:57 -070056 CPDFSDK_Annot::ObservedPtr* pAnnot,
tsepez9c33e892016-09-26 12:29:20 -070057 uint32_t nFlags);
58 void Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -070059 CPDFSDK_Annot::ObservedPtr* pAnnot,
tsepez9c33e892016-09-26 12:29:20 -070060 uint32_t nFlags);
tsepez4cf55152016-11-02 14:37:54 -070061 bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView,
62 CPDFSDK_Annot::ObservedPtr* pAnnot,
63 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050064 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070065 bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
66 CPDFSDK_Annot::ObservedPtr* pAnnot,
67 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050068 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070069 bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -070070 CPDFSDK_Annot::ObservedPtr* pAnnot,
tsepez9c33e892016-09-26 12:29:20 -070071 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050072 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070073 bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
74 CPDFSDK_Annot::ObservedPtr* pAnnot,
75 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050076 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070077 bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
78 CPDFSDK_Annot::ObservedPtr* pAnnot,
79 uint32_t nFlags,
80 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -050081 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070082 bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView,
83 CPDFSDK_Annot::ObservedPtr* pAnnot,
84 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050085 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070086 bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
87 CPDFSDK_Annot::ObservedPtr* pAnnot,
88 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050089 const CFX_PointF& point);
tsepez4cf55152016-11-02 14:37:54 -070090 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);
jaepark98e10192016-08-15 10:51:11 -070093
tsepez4cf55152016-11-02 14:37:54 -070094 bool Annot_OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag);
95 bool Annot_OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag);
jaepark98e10192016-08-15 10:51:11 -070096
97#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070098 bool Annot_OnChangeFocus(CPDFSDK_Annot::ObservedPtr* pSetAnnot,
99 CPDFSDK_Annot::ObservedPtr* pKillAnnot);
jaepark98e10192016-08-15 10:51:11 -0700100#endif // PDF_ENABLE_XFA
101
tsepez9c33e892016-09-26 12:29:20 -0700102 CFX_FloatRect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView,
103 CPDFSDK_Annot* pAnnot);
tsepez4cf55152016-11-02 14:37:54 -0700104 bool Annot_OnHitTest(CPDFSDK_PageView* pPageView,
105 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500106 const CFX_PointF& point);
jaepark98e10192016-08-15 10:51:11 -0700107
108 private:
jaepark956553e2016-08-31 06:49:27 -0700109 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDF_Annot::Subtype nSubtype) const;
tsepez4cf55152016-11-02 14:37:54 -0700110 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, bool bNext);
jaepark98e10192016-08-15 10:51:11 -0700111
jaepark35512aa2016-08-29 17:15:08 -0700112 std::unique_ptr<CPDFSDK_BAAnnotHandler> m_pBAAnnotHandler;
jaepark8c541822016-08-30 13:43:05 -0700113 std::unique_ptr<CPDFSDK_WidgetHandler> m_pWidgetHandler;
jaepark35512aa2016-08-29 17:15:08 -0700114#ifdef PDF_ENABLE_XFA
jaepark8c541822016-08-30 13:43:05 -0700115 std::unique_ptr<CPDFSDK_XFAWidgetHandler> m_pXFAWidgetHandler;
jaepark35512aa2016-08-29 17:15:08 -0700116#endif // PDF_ENABLE_XFA
jaepark98e10192016-08-15 10:51:11 -0700117};
118
dsinclair114e46a2016-09-29 17:18:21 -0700119#endif // FPDFSDK_CPDFSDK_ANNOTHANDLERMGR_H_