blob: 20744cc5bfdec9dacb6d11af44af168c72fd64c1 [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(
Tom Sepez49357702019-08-19 17:17:18 +000032 std::unique_ptr<CPDFSDK_BAAnnotHandler> pBAAnnotHandler,
33 std::unique_ptr<CPDFSDK_WidgetHandler> pWidgetHandler,
34 std::unique_ptr<IPDFSDK_AnnotHandler> pXFAWidgetHandler)
35 : m_pBAAnnotHandler(std::move(pBAAnnotHandler)),
36 m_pWidgetHandler(std::move(pWidgetHandler)),
37 m_pXFAWidgetHandler(std::move(pXFAWidgetHandler)) {
38 ASSERT(m_pBAAnnotHandler);
39 ASSERT(m_pWidgetHandler);
jaepark98e10192016-08-15 10:51:11 -070040}
41
Lei Zhang2ffc6282019-08-16 16:59:23 +000042CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() = default;
jaepark98e10192016-08-15 10:51:11 -070043
Tom Sepez49357702019-08-19 17:17:18 +000044void CPDFSDK_AnnotHandlerMgr::SetFormFillEnv(
45 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
46 m_pBAAnnotHandler->SetFormFillEnvironment(pFormFillEnv);
47 m_pWidgetHandler->SetFormFillEnvironment(pFormFillEnv);
48 if (m_pXFAWidgetHandler)
49 m_pXFAWidgetHandler->SetFormFillEnvironment(pFormFillEnv);
50}
51
jaepark98e10192016-08-15 10:51:11 -070052CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
53 CPDFSDK_PageView* pPageView) {
54 ASSERT(pPageView);
Lei Zhang2ffc6282019-08-16 16:59:23 +000055 return GetAnnotHandlerOfType(pAnnot->GetSubtype())
56 ->NewAnnot(pAnnot, pPageView);
jaepark98e10192016-08-15 10:51:11 -070057}
58
59#ifdef PDF_ENABLE_XFA
Lei Zhang2ffc6282019-08-16 16:59:23 +000060CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewXFAAnnot(
61 CXFA_FFWidget* pAnnot,
62 CPDFSDK_PageView* pPageView) {
jaepark98e10192016-08-15 10:51:11 -070063 ASSERT(pAnnot);
64 ASSERT(pPageView);
Tom Sepez49357702019-08-19 17:17:18 +000065 return static_cast<CPDFXFA_WidgetHandler*>(m_pXFAWidgetHandler.get())
66 ->NewAnnotForXFA(pAnnot, pPageView);
jaepark98e10192016-08-15 10:51:11 -070067}
68#endif // PDF_ENABLE_XFA
69
Tom Sepez0f35a9e2019-04-23 00:32:37 +000070void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(
71 std::unique_ptr<CPDFSDK_Annot> pAnnot) {
72 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot.get());
73 pAnnotHandler->ReleaseAnnot(std::move(pAnnot));
jaepark98e10192016-08-15 10:51:11 -070074}
75
jaepark98e10192016-08-15 10:51:11 -070076void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) {
77 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -070078 GetAnnotHandler(pAnnot)->OnLoad(pAnnot);
jaepark98e10192016-08-15 10:51:11 -070079}
80
Lei Zhanga4c7ac42018-04-17 15:12:58 +000081WideString CPDFSDK_AnnotHandlerMgr::Annot_GetText(CPDFSDK_Annot* pAnnot) {
82 return GetAnnotHandler(pAnnot)->GetText(pAnnot);
83}
84
Ryan Harrison275e2602017-09-18 14:23:18 -040085WideString CPDFSDK_AnnotHandlerMgr::Annot_GetSelectedText(
Diana Gagedce2d722017-06-20 11:17:11 -070086 CPDFSDK_Annot* pAnnot) {
87 return GetAnnotHandler(pAnnot)->GetSelectedText(pAnnot);
88}
89
Ryan Harrison275e2602017-09-18 14:23:18 -040090void CPDFSDK_AnnotHandlerMgr::Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot,
91 const WideString& text) {
Diana Gageab390972017-07-28 17:07:39 -070092 GetAnnotHandler(pAnnot)->ReplaceSelection(pAnnot, text);
Diana Gage1c7f1422017-07-24 11:19:52 -070093}
94
Lei Zhangee967722018-04-19 20:55:54 +000095bool CPDFSDK_AnnotHandlerMgr::Annot_CanUndo(CPDFSDK_Annot* pAnnot) {
96 return GetAnnotHandler(pAnnot)->CanUndo(pAnnot);
97}
98
99bool CPDFSDK_AnnotHandlerMgr::Annot_CanRedo(CPDFSDK_Annot* pAnnot) {
100 return GetAnnotHandler(pAnnot)->CanRedo(pAnnot);
101}
102
103bool CPDFSDK_AnnotHandlerMgr::Annot_Undo(CPDFSDK_Annot* pAnnot) {
104 return GetAnnotHandler(pAnnot)->Undo(pAnnot);
105}
106
107bool CPDFSDK_AnnotHandlerMgr::Annot_Redo(CPDFSDK_Annot* pAnnot) {
108 return GetAnnotHandler(pAnnot)->Redo(pAnnot);
109}
110
jaepark98e10192016-08-15 10:51:11 -0700111IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
112 CPDFSDK_Annot* pAnnot) const {
Lei Zhang2ffc6282019-08-16 16:59:23 +0000113 return GetAnnotHandlerOfType(pAnnot->GetAnnotSubtype());
jaepark98e10192016-08-15 10:51:11 -0700114}
115
Lei Zhang2ffc6282019-08-16 16:59:23 +0000116IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandlerOfType(
jaepark956553e2016-08-31 06:49:27 -0700117 CPDF_Annot::Subtype nAnnotSubtype) const {
118 if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET)
jaepark8c541822016-08-30 13:43:05 -0700119 return m_pWidgetHandler.get();
jaepark35512aa2016-08-29 17:15:08 -0700120
121#ifdef PDF_ENABLE_XFA
jaepark956553e2016-08-31 06:49:27 -0700122 if (nAnnotSubtype == CPDF_Annot::Subtype::XFAWIDGET)
jaepark8c541822016-08-30 13:43:05 -0700123 return m_pXFAWidgetHandler.get();
jaepark35512aa2016-08-29 17:15:08 -0700124#endif // PDF_ENABLE_XFA
125
126 return m_pBAAnnotHandler.get();
jaepark98e10192016-08-15 10:51:11 -0700127}
128
129void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
130 CPDFSDK_Annot* pAnnot,
131 CFX_RenderDevice* pDevice,
Lei Zhang09ee0872018-10-09 19:13:55 +0000132 const CFX_Matrix& mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -0700133 bool bDrawAnnots) {
jaepark98e10192016-08-15 10:51:11 -0700134 ASSERT(pAnnot);
Lei Zhang09ee0872018-10-09 19:13:55 +0000135 GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -0700136 bDrawAnnots);
jaepark98e10192016-08-15 10:51:11 -0700137}
138
tsepez4cf55152016-11-02 14:37:54 -0700139bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
jaepark98e10192016-08-15 10:51:11 -0700140 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000141 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700142 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500143 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000144 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700145 return GetAnnotHandler(pAnnot->Get())
146 ->OnLButtonDown(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700147}
148
tsepez4cf55152016-11-02 14:37:54 -0700149bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
jaepark98e10192016-08-15 10:51:11 -0700150 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000151 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700152 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500153 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000154 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700155 return GetAnnotHandler(pAnnot->Get())
156 ->OnLButtonUp(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700157}
158
Lei Zhanga37989f2018-10-17 20:32:41 +0000159bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
160 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000161 ObservedPtr<CPDFSDK_Annot>* pAnnot,
Lei Zhanga37989f2018-10-17 20:32:41 +0000162 uint32_t nFlags,
163 const CFX_PointF& point) {
164 ASSERT(pAnnot->HasObservable());
165 return GetAnnotHandler(pAnnot->Get())
166 ->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
167}
168
tsepez4cf55152016-11-02 14:37:54 -0700169bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
jaepark98e10192016-08-15 10:51:11 -0700170 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000171 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700172 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500173 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000174 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700175 return GetAnnotHandler(pAnnot->Get())
176 ->OnMouseMove(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700177}
178
tsepez4cf55152016-11-02 14:37:54 -0700179bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
jaepark98e10192016-08-15 10:51:11 -0700180 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000181 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700182 uint32_t nFlags,
183 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500184 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000185 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700186 return GetAnnotHandler(pAnnot->Get())
187 ->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
jaepark98e10192016-08-15 10:51:11 -0700188}
189
tsepez4cf55152016-11-02 14:37:54 -0700190bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
jaepark98e10192016-08-15 10:51:11 -0700191 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000192 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700193 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500194 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000195 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700196 return GetAnnotHandler(pAnnot->Get())
197 ->OnRButtonDown(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700198}
199
tsepez4cf55152016-11-02 14:37:54 -0700200bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
jaepark98e10192016-08-15 10:51:11 -0700201 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000202 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark98e10192016-08-15 10:51:11 -0700203 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500204 const CFX_PointF& point) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000205 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700206 return GetAnnotHandler(pAnnot->Get())
207 ->OnRButtonUp(pPageView, pAnnot, nFlags, point);
jaepark98e10192016-08-15 10:51:11 -0700208}
209
tsepezf8074ce2016-09-27 14:29:57 -0700210void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
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())->OnMouseEnter(pPageView, pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700216}
217
tsepezf8074ce2016-09-27 14:29:57 -0700218void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
219 CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000220 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700221 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000222 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700223 GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700224}
225
tsepez4cf55152016-11-02 14:37:54 -0700226bool CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
227 uint32_t nChar,
228 uint32_t nFlags) {
jaepark35512aa2016-08-29 17:15:08 -0700229 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
jaepark98e10192016-08-15 10:51:11 -0700230}
231
tsepez4cf55152016-11-02 14:37:54 -0700232bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
233 int nKeyCode,
234 int nFlag) {
Tom Sepez43f012f2019-08-02 16:16:46 +0000235 if (CPWL_Wnd::IsCTRLKeyDown(nFlag) || CPWL_Wnd::IsALTKeyDown(nFlag)) {
jaepark35512aa2016-08-29 17:15:08 -0700236 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
thestig7b3252f2016-11-08 21:30:11 -0800237 }
huyna6e3a4062019-07-25 20:41:23 +0000238 ObservedPtr<CPDFSDK_Annot> pObservedAnnot(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700239 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
240 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
241 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) {
Tom Sepez43f012f2019-08-02 16:16:46 +0000242 ObservedPtr<CPDFSDK_Annot> pNext(
243 GetNextAnnot(pFocusAnnot, !CPWL_Wnd::IsSHIFTKeyDown(nFlag)));
tsepezf8074ce2016-09-27 14:29:57 -0700244 if (pNext && pNext.Get() != pFocusAnnot) {
dsinclair7cbe68e2016-10-12 11:56:23 -0700245 pPage->GetFormFillEnv()->SetFocusAnnot(&pNext);
tsepez4cf55152016-11-02 14:37:54 -0700246 return true;
jaepark98e10192016-08-15 10:51:11 -0700247 }
248 }
249
huyna6e3a4062019-07-25 20:41:23 +0000250 // Check |pAnnot| again because JS may have destroyed it in |GetNextAnnot|
251 if (!pObservedAnnot)
252 return false;
253
thestig7b3252f2016-11-08 21:30:11 -0800254 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700255}
256
tsepez4cf55152016-11-02 14:37:54 -0700257bool CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000258 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700259 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000260 ASSERT(pAnnot->HasObservable());
dsinclairb402b172016-10-11 09:26:32 -0700261 return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700262}
263
tsepez4cf55152016-11-02 14:37:54 -0700264bool CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000265 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepezf8074ce2016-09-27 14:29:57 -0700266 uint32_t nFlag) {
Lei Zhangf0b7d592018-10-10 18:54:24 +0000267 ASSERT(pAnnot->HasObservable());
tsepezf8074ce2016-09-27 14:29:57 -0700268 return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
jaepark98e10192016-08-15 10:51:11 -0700269}
270
rycsmitha5230e22019-02-21 17:33:03 +0000271bool CPDFSDK_AnnotHandlerMgr::Annot_SetIndexSelected(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000272 ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000273 int index,
274 bool selected) {
275 return GetAnnotHandler(pAnnot->Get())
276 ->SetIndexSelected(pAnnot, index, selected);
277}
278
279bool CPDFSDK_AnnotHandlerMgr::Annot_IsIndexSelected(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000280 ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000281 int index) {
282 return GetAnnotHandler(pAnnot->Get())->IsIndexSelected(pAnnot, index);
283}
284
jaepark98e10192016-08-15 10:51:11 -0700285#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700286bool CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000287 ObservedPtr<CPDFSDK_Annot>* pSetAnnot,
288 ObservedPtr<CPDFSDK_Annot>* pKillAnnot) {
tsepez4cf55152016-11-02 14:37:54 -0700289 bool bXFA = (*pSetAnnot && (*pSetAnnot)->GetXFAWidget()) ||
290 (*pKillAnnot && (*pKillAnnot)->GetXFAWidget());
Tom Sepez49357702019-08-19 17:17:18 +0000291
292 return !bXFA || static_cast<CPDFXFA_WidgetHandler*>(m_pXFAWidgetHandler.get())
293 ->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
jaepark98e10192016-08-15 10:51:11 -0700294}
295#endif // PDF_ENABLE_XFA
296
297CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
298 CPDFSDK_PageView* pPageView,
299 CPDFSDK_Annot* pAnnot) {
300 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700301 return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot);
jaepark98e10192016-08-15 10:51:11 -0700302}
303
tsepez4cf55152016-11-02 14:37:54 -0700304bool CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
305 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500306 const CFX_PointF& point) {
jaepark98e10192016-08-15 10:51:11 -0700307 ASSERT(pAnnot);
jaepark35512aa2016-08-29 17:15:08 -0700308 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot);
309 if (pAnnotHandler->CanAnswer(pAnnot))
310 return pAnnotHandler->HitTest(pPageView, pAnnot, point);
311
tsepez4cf55152016-11-02 14:37:54 -0700312 return false;
jaepark98e10192016-08-15 10:51:11 -0700313}
314
315CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700316 bool bNext) {
jaepark98e10192016-08-15 10:51:11 -0700317#ifdef PDF_ENABLE_XFA
Tom Sepez9bf01812019-08-19 18:59:27 +0000318 IPDF_Page* pPage = pSDKAnnot->GetPageView()->GetXFAPage();
Tom Sepez8e631772018-06-13 21:26:56 +0000319 if (pPage && !pPage->AsPDFPage()) {
320 // For xfa annots in XFA pages not backed by PDF pages.
Tom Sepez9bf01812019-08-19 18:59:27 +0000321 return static_cast<CPDFXFA_Page*>(pPage)->GetNextXFAAnnot(pSDKAnnot, bNext);
Tom Sepez8e631772018-06-13 21:26:56 +0000322 }
jaepark98e10192016-08-15 10:51:11 -0700323#endif // PDF_ENABLE_XFA
Tom Sepez8e631772018-06-13 21:26:56 +0000324
325 // For PDF annots.
Tom Sepez11a6bec2018-07-25 23:25:55 +0000326 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pSDKAnnot);
327 CPDFSDK_AnnotIterator ai(pWidget->GetPageView(), pWidget->GetAnnotSubtype());
328 return bNext ? ai.GetNextAnnot(pWidget) : ai.GetPrevAnnot(pWidget);
jaepark98e10192016-08-15 10:51:11 -0700329}