blob: d72d39e25686d26cbcc7041567d07e7eefe1d46f [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#include "fpdfsdk/cpdfsdk_annothandlermgr.h"
jaepark98e10192016-08-15 10:51:11 -07008
Tom Sepez0f35a9e2019-04-23 00:32:37 +00009#include <utility>
10
tsepez0e606b52016-11-18 16:22:41 -080011#include "core/fpdfapi/parser/cpdf_number.h"
12#include "core/fpdfapi/parser/cpdf_string.h"
dsinclair1727aee2016-09-29 13:12:56 -070013#include "core/fpdfdoc/cpdf_annot.h"
dsinclair114e46a2016-09-29 17:18:21 -070014#include "fpdfsdk/cpdfsdk_annot.h"
Dan Sinclaircbf76e62018-03-28 21:00:35 +000015#include "fpdfsdk/cpdfsdk_annotiterator.h"
dsinclair114e46a2016-09-29 17:18:21 -070016#include "fpdfsdk/cpdfsdk_baannot.h"
17#include "fpdfsdk/cpdfsdk_baannothandler.h"
dsinclair735606d2016-10-05 15:47:02 -070018#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
dsinclair114e46a2016-09-29 17:18:21 -070019#include "fpdfsdk/cpdfsdk_pageview.h"
Tom Sepez11a6bec2018-07-25 23:25:55 +000020#include "fpdfsdk/cpdfsdk_widget.h"
dsinclair114e46a2016-09-29 17:18:21 -070021#include "fpdfsdk/cpdfsdk_widgethandler.h"
Tom Sepez43f012f2019-08-02 16:16:46 +000022#include "fpdfsdk/pwl/cpwl_wnd.h"
Lei Zhangac756642018-12-13 20:47:10 +000023#include "public/fpdf_fwlevent.h"
Tom Sepezfe91c6c2017-05-16 15:33:20 -070024#include "third_party/base/ptr_util.h"
jaepark98e10192016-08-15 10:51:11 -070025
26#ifdef PDF_ENABLE_XFA
dsinclair4d29e782016-10-04 14:02:47 -070027#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
Tom Sepezf89a43f2019-08-09 19:55:49 +000028#include "fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h"
jaepark98e10192016-08-15 10:51:11 -070029#endif // PDF_ENABLE_XFA
30
dsinclair735606d2016-10-05 15:47:02 -070031CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(
dsinclair8779fa82016-10-12 12:05:44 -070032 CPDFSDK_FormFillEnvironment* pFormFillEnv)
Tom Sepezfe91c6c2017-05-16 15:33:20 -070033 : m_pBAAnnotHandler(pdfium::MakeUnique<CPDFSDK_BAAnnotHandler>()),
Lei Zhang60fa2fc2017-07-21 17:42:19 -070034 m_pWidgetHandler(pdfium::MakeUnique<CPDFSDK_WidgetHandler>(pFormFillEnv))
jaepark98e10192016-08-15 10:51:11 -070035#ifdef PDF_ENABLE_XFA
Lei Zhang60fa2fc2017-07-21 17:42:19 -070036 ,
Tom Sepezfe91c6c2017-05-16 15:33:20 -070037 m_pXFAWidgetHandler(
Tom Sepezf89a43f2019-08-09 19:55:49 +000038 pdfium::MakeUnique<CPDFXFA_WidgetHandler>(pFormFillEnv))
jaepark98e10192016-08-15 10:51:11 -070039#endif // PDF_ENABLE_XFA
Lei Zhang60fa2fc2017-07-21 17:42:19 -070040{
jaepark98e10192016-08-15 10:51:11 -070041}
42
43CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {}
44
jaepark98e10192016-08-15 10:51:11 -070045CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
46 CPDFSDK_PageView* pPageView) {
47 ASSERT(pPageView);
jaepark35512aa2016-08-29 17:15:08 -070048 return GetAnnotHandler(pAnnot->GetSubtype())->NewAnnot(pAnnot, pPageView);
jaepark98e10192016-08-15 10:51:11 -070049}
50
51#ifdef PDF_ENABLE_XFA
52CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot,
53 CPDFSDK_PageView* pPageView) {
54 ASSERT(pAnnot);
55 ASSERT(pPageView);
56
jaepark956553e2016-08-31 06:49:27 -070057 return GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)
58 ->NewAnnot(pAnnot, pPageView);
jaepark98e10192016-08-15 10:51:11 -070059}
60#endif // PDF_ENABLE_XFA
61
Tom Sepez0f35a9e2019-04-23 00:32:37 +000062void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(
63 std::unique_ptr<CPDFSDK_Annot> pAnnot) {
64 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot.get());
65 pAnnotHandler->ReleaseAnnot(std::move(pAnnot));
jaepark98e10192016-08-15 10:51:11 -070066}
67
jaepark98e10192016-08-15 10:51:11 -070068void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) {
69 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -070070 GetAnnotHandler(pAnnot)->OnLoad(pAnnot);
jaepark98e10192016-08-15 10:51:11 -070071}
72
Lei Zhanga4c7ac42018-04-17 15:12:58 +000073WideString CPDFSDK_AnnotHandlerMgr::Annot_GetText(CPDFSDK_Annot* pAnnot) {
74 return GetAnnotHandler(pAnnot)->GetText(pAnnot);
75}
76
Ryan Harrison275e2602017-09-18 14:23:18 -040077WideString CPDFSDK_AnnotHandlerMgr::Annot_GetSelectedText(
Diana Gagedce2d722017-06-20 11:17:11 -070078 CPDFSDK_Annot* pAnnot) {
79 return GetAnnotHandler(pAnnot)->GetSelectedText(pAnnot);
80}
81
Ryan Harrison275e2602017-09-18 14:23:18 -040082void CPDFSDK_AnnotHandlerMgr::Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot,
83 const WideString& text) {
Diana Gageab390972017-07-28 17:07:39 -070084 GetAnnotHandler(pAnnot)->ReplaceSelection(pAnnot, text);
Diana Gage1c7f1422017-07-24 11:19:52 -070085}
86
Lei Zhangee967722018-04-19 20:55:54 +000087bool CPDFSDK_AnnotHandlerMgr::Annot_CanUndo(CPDFSDK_Annot* pAnnot) {
88 return GetAnnotHandler(pAnnot)->CanUndo(pAnnot);
89}
90
91bool CPDFSDK_AnnotHandlerMgr::Annot_CanRedo(CPDFSDK_Annot* pAnnot) {
92 return GetAnnotHandler(pAnnot)->CanRedo(pAnnot);
93}
94
95bool CPDFSDK_AnnotHandlerMgr::Annot_Undo(CPDFSDK_Annot* pAnnot) {
96 return GetAnnotHandler(pAnnot)->Undo(pAnnot);
97}
98
99bool CPDFSDK_AnnotHandlerMgr::Annot_Redo(CPDFSDK_Annot* pAnnot) {
100 return GetAnnotHandler(pAnnot)->Redo(pAnnot);
101}
102
jaepark98e10192016-08-15 10:51:11 -0700103IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
104 CPDFSDK_Annot* pAnnot) const {
jaepark35512aa2016-08-29 17:15:08 -0700105 return GetAnnotHandler(pAnnot->GetAnnotSubtype());
jaepark98e10192016-08-15 10:51:11 -0700106}
107
108IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
jaepark956553e2016-08-31 06:49:27 -0700109 CPDF_Annot::Subtype nAnnotSubtype) const {
110 if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET)
jaepark8c541822016-08-30 13:43:05 -0700111 return m_pWidgetHandler.get();
jaepark35512aa2016-08-29 17:15:08 -0700112
113#ifdef PDF_ENABLE_XFA
jaepark956553e2016-08-31 06:49:27 -0700114 if (nAnnotSubtype == CPDF_Annot::Subtype::XFAWIDGET)
jaepark8c541822016-08-30 13:43:05 -0700115 return m_pXFAWidgetHandler.get();
jaepark35512aa2016-08-29 17:15:08 -0700116#endif // PDF_ENABLE_XFA
117
118 return m_pBAAnnotHandler.get();
jaepark98e10192016-08-15 10:51:11 -0700119}
120
121void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
122 CPDFSDK_Annot* pAnnot,
123 CFX_RenderDevice* pDevice,
Lei Zhang09ee0872018-10-09 19:13:55 +0000124 const CFX_Matrix& mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -0700125 bool bDrawAnnots) {
jaepark98e10192016-08-15 10:51:11 -0700126 ASSERT(pAnnot);
Lei Zhang09ee0872018-10-09 19:13:55 +0000127 GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -0700128 bDrawAnnots);
jaepark98e10192016-08-15 10:51:11 -0700129}
130
tsepez4cf55152016-11-02 14:37:54 -0700131bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
jaepark98e10192016-08-15 10:51:11 -0700132 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000133 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700134 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500135 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000136 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700137 return GetAnnotHandler(pAnnot->Get())
138 ->OnLButtonDown(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700139}
140
tsepez4cf55152016-11-02 14:37:54 -0700141bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
jaepark98e10192016-08-15 10:51:11 -0700142 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000143 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700144 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500145 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000146 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700147 return GetAnnotHandler(pAnnot->Get())
148 ->OnLButtonUp(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700149}
150
Lei Zhanga37989f2018-10-17 20:32:41 +0000151bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
152 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000153 ObservedPtr<CPDFSDK_Annot>* pAnnot,
Lei Zhanga37989f2018-10-17 20:32:41 +0000154 uint32_t nFlags,
155 const CFX_PointF& point) {
156 ASSERT(pAnnot->HasObservable());
157 return GetAnnotHandler(pAnnot->Get())
158 ->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
159}
160
tsepez4cf55152016-11-02 14:37:54 -0700161bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
jaepark98e10192016-08-15 10:51:11 -0700162 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000163 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700164 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500165 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000166 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700167 return GetAnnotHandler(pAnnot->Get())
168 ->OnMouseMove(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700169}
170
tsepez4cf55152016-11-02 14:37:54 -0700171bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
jaepark98e10192016-08-15 10:51:11 -0700172 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000173 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700174 uint32_t nFlags,
175 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500176 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000177 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700178 return GetAnnotHandler(pAnnot->Get())
179 ->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
jaepark98e10192016-08-15 10:51:11 -0700180}
181
tsepez4cf55152016-11-02 14:37:54 -0700182bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
jaepark98e10192016-08-15 10:51:11 -0700183 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000184 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700185 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500186 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000187 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700188 return GetAnnotHandler(pAnnot->Get())
189 ->OnRButtonDown(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700190}
191
tsepez4cf55152016-11-02 14:37:54 -0700192bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
jaepark98e10192016-08-15 10:51:11 -0700193 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000194 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700195 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500196 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000197 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700198 return GetAnnotHandler(pAnnot->Get())
199 ->OnRButtonUp(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700200}
201
tsepezf8074ce2016-09-27 14:29:57 -0700202void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
203 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000204 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700205 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000206 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700207 GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700208}
209
tsepezf8074ce2016-09-27 14:29:57 -0700210void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
211 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000212 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700213 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000214 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700215 GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700216}
217
tsepez4cf55152016-11-02 14:37:54 -0700218bool CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
219 uint32_t nChar,
220 uint32_t nFlags) {
jaepark35512aa2016-08-29 17:15:08 -0700221 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
jaepark98e10192016-08-15 10:51:11 -0700222}
223
tsepez4cf55152016-11-02 14:37:54 -0700224bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
225 int nKeyCode,
226 int nFlag) {
Tom Sepez43f012f2019-08-02 16:16:46 +0000227 if (CPWL_Wnd::IsCTRLKeyDown(nFlag) || CPWL_Wnd::IsALTKeyDown(nFlag)) {
jaepark35512aa2016-08-29 17:15:08 -0700228 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
thestig7b3252f2016-11-08 21:30:11 -0800229 }
huyna6e3a4062019-07-25 20:41:23 +0000230 ObservedPtr<CPDFSDK_Annot> pObservedAnnot(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700231 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
232 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
233 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) {
Tom Sepez43f012f2019-08-02 16:16:46 +0000234 ObservedPtr<CPDFSDK_Annot> pNext(
235 GetNextAnnot(pFocusAnnot, !CPWL_Wnd::IsSHIFTKeyDown(nFlag)));
tsepezf8074ce2016-09-27 14:29:57 -0700236 if (pNext && pNext.Get() != pFocusAnnot) {
dsinclair7cbe68e2016-10-12 11:56:23 -0700237 pPage->GetFormFillEnv()->SetFocusAnnot(&pNext);
tsepez4cf55152016-11-02 14:37:54 -0700238 return true;
jaepark98e10192016-08-15 10:51:11 -0700239 }
240 }
241
huyna6e3a4062019-07-25 20:41:23 +0000242 // Check |pAnnot| again because JS may have destroyed it in |GetNextAnnot|
243 if (!pObservedAnnot)
244 return false;
245
thestig7b3252f2016-11-08 21:30:11 -0800246 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700247}
248
tsepez4cf55152016-11-02 14:37:54 -0700249bool CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000250 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700251 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000252 ASSERT(pAnnot->HasObservable());
dsinclairb402b172016-10-11 09:26:32 -0700253 return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700254}
255
tsepez4cf55152016-11-02 14:37:54 -0700256bool CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000257 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700258 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000259 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700260 return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700261}
262
rycsmitha5230e22019-02-21 17:33:03 +0000263bool CPDFSDK_AnnotHandlerMgr::Annot_SetIndexSelected(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000264 ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000265 int index,
266 bool selected) {
267 return GetAnnotHandler(pAnnot->Get())
268 ->SetIndexSelected(pAnnot, index, selected);
269}
270
271bool CPDFSDK_AnnotHandlerMgr::Annot_IsIndexSelected(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000272 ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000273 int index) {
274 return GetAnnotHandler(pAnnot->Get())->IsIndexSelected(pAnnot, index);
275}
276
jaepark98e10192016-08-15 10:51:11 -0700277#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700278bool CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000279 ObservedPtr<CPDFSDK_Annot>* pSetAnnot,
280 ObservedPtr<CPDFSDK_Annot>* pKillAnnot) {
tsepez4cf55152016-11-02 14:37:54 -0700281 bool bXFA = (*pSetAnnot && (*pSetAnnot)->GetXFAWidget()) ||
282 (*pKillAnnot && (*pKillAnnot)->GetXFAWidget());
jaepark98e10192016-08-15 10:51:11 -0700283
284 if (bXFA) {
285 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler =
jaepark956553e2016-08-31 06:49:27 -0700286 GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET))
jaepark98e10192016-08-15 10:51:11 -0700287 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
288 }
289
tsepez4cf55152016-11-02 14:37:54 -0700290 return true;
jaepark98e10192016-08-15 10:51:11 -0700291}
292#endif // PDF_ENABLE_XFA
293
294CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
295 CPDFSDK_PageView* pPageView,
296 CPDFSDK_Annot* pAnnot) {
297 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700298 return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot);
jaepark98e10192016-08-15 10:51:11 -0700299}
300
tsepez4cf55152016-11-02 14:37:54 -0700301bool CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
302 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500303 const CFX_PointF& point) {
jaepark98e10192016-08-15 10:51:11 -0700304 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700305 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot);
306 if (pAnnotHandler->CanAnswer(pAnnot))
307 return pAnnotHandler->HitTest(pPageView, pAnnot, point);
308
tsepez4cf55152016-11-02 14:37:54 -0700309 return false;
jaepark98e10192016-08-15 10:51:11 -0700310}
311
312CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700313 bool bNext) {
jaepark98e10192016-08-15 10:51:11 -0700314#ifdef PDF_ENABLE_XFA
Tom Sepezffb51092019-08-09 19:27:25 +0000315 CPDFXFA_Page* pPage = pSDKAnnot->GetPageView()->GetPDFXFAPage();
Tom Sepez8e631772018-06-13 21:26:56 +0000316 if (pPage && !pPage->AsPDFPage()) {
317 // For xfa annots in XFA pages not backed by PDF pages.
Tom Sepezffb51092019-08-09 19:27:25 +0000318 return pPage->GetNextXFAAnnot(pSDKAnnot, bNext);
Tom Sepez8e631772018-06-13 21:26:56 +0000319 }
jaepark98e10192016-08-15 10:51:11 -0700320#endif // PDF_ENABLE_XFA
Tom Sepez8e631772018-06-13 21:26:56 +0000321
322 // For PDF annots.
Tom Sepez11a6bec2018-07-25 23:25:55 +0000323 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pSDKAnnot);
324 CPDFSDK_AnnotIterator ai(pWidget->GetPageView(), pWidget->GetAnnotSubtype());
325 return bNext ? ai.GetNextAnnot(pWidget) : ai.GetPrevAnnot(pWidget);
jaepark98e10192016-08-15 10:51:11 -0700326}