blob: 74e7512e4287e1bc2806f7a5d7132a7e8100348b [file] [log] [blame]
jaepark8c541822016-08-30 13:43:05 -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_widgethandler.h"
jaepark8c541822016-08-30 13:43:05 -07008
9#include <memory>
10#include <vector>
11
Lei Zhanga676aca2019-02-02 00:41:09 +000012#include "constants/form_flags.h"
dsinclair41872fa2016-10-04 11:29:35 -070013#include "core/fpdfapi/page/cpdf_page.h"
dsinclair488b7ad2016-10-04 11:55:50 -070014#include "core/fpdfapi/parser/cpdf_document.h"
Lei Zhangc3450652018-10-11 16:54:42 +000015#include "core/fpdfdoc/cpdf_interactiveform.h"
dsinclair114e46a2016-09-29 17:18:21 -070016#include "fpdfsdk/cpdfsdk_annot.h"
dsinclair735606d2016-10-05 15:47:02 -070017#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
Lei Zhangc3450652018-10-11 16:54:42 +000018#include "fpdfsdk/cpdfsdk_interactiveform.h"
dsinclair114e46a2016-09-29 17:18:21 -070019#include "fpdfsdk/cpdfsdk_pageview.h"
20#include "fpdfsdk/cpdfsdk_widget.h"
jaepark8c541822016-08-30 13:43:05 -070021#include "fpdfsdk/formfiller/cffl_formfiller.h"
jaepark8c541822016-08-30 13:43:05 -070022
23#ifdef PDF_ENABLE_XFA
dsinclair521b7502016-11-02 13:02:28 -070024#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
jaepark8c541822016-08-30 13:43:05 -070025#endif // PDF_ENABLE_XFA
26
dsinclair8779fa82016-10-12 12:05:44 -070027CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler(
28 CPDFSDK_FormFillEnvironment* pFormFillEnv)
Lei Zhang60fa2fc2017-07-21 17:42:19 -070029 : m_pFormFillEnv(pFormFillEnv),
Lei Zhang7db136a2018-10-10 21:34:17 +000030 m_pFormFiller(pFormFillEnv->GetInteractiveFormFiller()) {
31 ASSERT(m_pFormFillEnv);
32 ASSERT(m_pFormFiller);
33}
jaepark8c541822016-08-30 13:43:05 -070034
Lei Zhang7db136a2018-10-10 21:34:17 +000035CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() = default;
jaepark8c541822016-08-30 13:43:05 -070036
tsepez4cf55152016-11-02 14:37:54 -070037bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
Tom Sepez11a6bec2018-07-25 23:25:55 +000038 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
39 if (pWidget->IsSignatureWidget())
tsepez4cf55152016-11-02 14:37:54 -070040 return false;
jaepark8c541822016-08-30 13:43:05 -070041
jaepark8c541822016-08-30 13:43:05 -070042 if (!pWidget->IsVisible())
tsepez4cf55152016-11-02 14:37:54 -070043 return false;
jaepark8c541822016-08-30 13:43:05 -070044
45 int nFieldFlags = pWidget->GetFieldFlags();
Lei Zhanga676aca2019-02-02 00:41:09 +000046 if (nFieldFlags & pdfium::form_flags::kReadOnly)
tsepez4cf55152016-11-02 14:37:54 -070047 return false;
jaepark8c541822016-08-30 13:43:05 -070048
Ryan Harrison9baf31f2018-01-12 18:36:30 +000049 if (pWidget->GetFieldType() == FormFieldType::kPushButton)
tsepez4cf55152016-11-02 14:37:54 -070050 return true;
jaepark8c541822016-08-30 13:43:05 -070051
52 CPDF_Page* pPage = pWidget->GetPDFPage();
Lei Zhang8f637632018-05-07 23:36:26 +000053 uint32_t dwPermissions = pPage->GetDocument()->GetUserPermissions();
jaepark8c541822016-08-30 13:43:05 -070054 return (dwPermissions & FPDFPERM_FILL_FORM) ||
55 (dwPermissions & FPDFPERM_ANNOT_FORM);
56}
57
58CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot,
59 CPDFSDK_PageView* pPage) {
Lei Zhang073ecf42018-10-11 16:56:00 +000060 CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm();
61 CPDF_InteractiveForm* pPDFForm = pForm->GetInteractiveForm();
62 CPDF_FormControl* pCtrl = pPDFForm->GetControlByDict(pAnnot->GetAnnotDict());
jaepark8c541822016-08-30 13:43:05 -070063 if (!pCtrl)
64 return nullptr;
65
Lei Zhang073ecf42018-10-11 16:56:00 +000066 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pForm);
67 pForm->AddMap(pCtrl, pWidget);
68 if (pPDFForm->NeedConstructAP())
Lei Zhang4f261ff2018-10-10 18:44:45 +000069 pWidget->ResetAppearance(pdfium::nullopt, false);
jaepark8c541822016-08-30 13:43:05 -070070 return pWidget;
71}
72
73#ifdef PDF_ENABLE_XFA
74CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CXFA_FFWidget* hWidget,
75 CPDFSDK_PageView* pPage) {
76 return nullptr;
77}
78#endif // PDF_ENABLE_XFA
79
Tom Sepez0f35a9e2019-04-23 00:32:37 +000080void CPDFSDK_WidgetHandler::ReleaseAnnot(
81 std::unique_ptr<CPDFSDK_Annot> pAnnot) {
jaepark8c541822016-08-30 13:43:05 -070082 ASSERT(pAnnot);
Tom Sepez0f35a9e2019-04-23 00:32:37 +000083 m_pFormFiller->OnDelete(pAnnot.get());
jaepark8c541822016-08-30 13:43:05 -070084
Tom Sepez0f35a9e2019-04-23 00:32:37 +000085 std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.release()));
Lei Zhang073ecf42018-10-11 16:56:00 +000086 CPDFSDK_InteractiveForm* pForm = pWidget->GetInteractiveForm();
jaepark8c541822016-08-30 13:43:05 -070087 CPDF_FormControl* pControl = pWidget->GetFormControl();
Lei Zhang073ecf42018-10-11 16:56:00 +000088 pForm->RemoveMap(pControl);
jaepark8c541822016-08-30 13:43:05 -070089}
90
jaepark8c541822016-08-30 13:43:05 -070091void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
92 CPDFSDK_Annot* pAnnot,
93 CFX_RenderDevice* pDevice,
Lei Zhang09ee0872018-10-09 19:13:55 +000094 const CFX_Matrix& mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -070095 bool bDrawAnnots) {
jaepark8c541822016-08-30 13:43:05 -070096 if (pAnnot->IsSignatureWidget()) {
Lei Zhang09ee0872018-10-09 19:13:55 +000097 pAnnot->AsBAAnnot()->DrawAppearance(pDevice, mtUser2Device,
Tom Sepez522d77d2018-07-28 00:00:25 +000098 CPDF_Annot::Normal, nullptr);
jaepark8c541822016-08-30 13:43:05 -070099 } else {
Lei Zhang7db136a2018-10-10 21:34:17 +0000100 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device);
jaepark8c541822016-08-30 13:43:05 -0700101 }
102}
103
jaepark8c541822016-08-30 13:43:05 -0700104void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000105 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700106 uint32_t nFlag) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000107 if (!(*pAnnot)->IsSignatureWidget())
jaepark8c541822016-08-30 13:43:05 -0700108 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
109}
110
111void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000112 ObservedPtr<CPDFSDK_Annot>* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700113 uint32_t nFlag) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000114 if (!(*pAnnot)->IsSignatureWidget())
jaepark8c541822016-08-30 13:43:05 -0700115 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
116}
117
tsepez4cf55152016-11-02 14:37:54 -0700118bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000119 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700120 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500121 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000122 return !(*pAnnot)->IsSignatureWidget() &&
123 m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700124}
125
tsepez4cf55152016-11-02 14:37:54 -0700126bool CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000127 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700128 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500129 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000130 return !(*pAnnot)->IsSignatureWidget() &&
131 m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700132}
133
tsepez4cf55152016-11-02 14:37:54 -0700134bool CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000135 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700136 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500137 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000138 return !(*pAnnot)->IsSignatureWidget() &&
139 m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700140}
141
tsepez4cf55152016-11-02 14:37:54 -0700142bool CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000143 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700144 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500145 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000146 return !(*pAnnot)->IsSignatureWidget() &&
147 m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700148}
149
tsepez4cf55152016-11-02 14:37:54 -0700150bool CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000151 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700152 uint32_t nFlags,
153 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500154 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000155 return !(*pAnnot)->IsSignatureWidget() &&
156 m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
jaepark8c541822016-08-30 13:43:05 -0700157}
158
tsepez4cf55152016-11-02 14:37:54 -0700159bool CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000160 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700161 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500162 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000163 return !(*pAnnot)->IsSignatureWidget() &&
164 m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700165}
166
tsepez4cf55152016-11-02 14:37:54 -0700167bool CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000168 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700169 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500170 const CFX_PointF& point) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000171 return !(*pAnnot)->IsSignatureWidget() &&
172 m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
jaepark8c541822016-08-30 13:43:05 -0700173}
174
tsepez4cf55152016-11-02 14:37:54 -0700175bool CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000176 ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700177 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500178 const CFX_PointF& point) {
tsepez4cf55152016-11-02 14:37:54 -0700179 return false;
jaepark8c541822016-08-30 13:43:05 -0700180}
181
tsepez4cf55152016-11-02 14:37:54 -0700182bool CPDFSDK_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
183 uint32_t nChar,
184 uint32_t nFlags) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000185 return !pAnnot->IsSignatureWidget() &&
186 m_pFormFiller->OnChar(pAnnot, nChar, nFlags);
jaepark8c541822016-08-30 13:43:05 -0700187}
188
tsepez4cf55152016-11-02 14:37:54 -0700189bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
190 int nKeyCode,
191 int nFlag) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000192 return !pAnnot->IsSignatureWidget() &&
193 m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag);
jaepark8c541822016-08-30 13:43:05 -0700194}
195
tsepez4cf55152016-11-02 14:37:54 -0700196bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
197 int nKeyCode,
198 int nFlag) {
199 return false;
jaepark8c541822016-08-30 13:43:05 -0700200}
201
jaepark8c541822016-08-30 13:43:05 -0700202void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
203 if (pAnnot->IsSignatureWidget())
204 return;
205
Tom Sepez4ef943b2018-07-26 19:06:06 +0000206 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
jaepark8c541822016-08-30 13:43:05 -0700207 if (!pWidget->IsAppearanceValid())
Lei Zhang4f261ff2018-10-10 18:44:45 +0000208 pWidget->ResetAppearance(pdfium::nullopt, false);
jaepark8c541822016-08-30 13:43:05 -0700209
Ryan Harrison9baf31f2018-01-12 18:36:30 +0000210 FormFieldType fieldType = pWidget->GetFieldType();
211 if (fieldType == FormFieldType::kTextField ||
212 fieldType == FormFieldType::kComboBox) {
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000213 ObservedPtr<CPDFSDK_Annot> pObserved(pWidget);
Lei Zhang4f261ff2018-10-10 18:44:45 +0000214 Optional<WideString> sValue = pWidget->OnFormat();
Lei Zhangcd8ff7e2017-06-13 14:09:46 -0700215 if (!pObserved)
216 return;
217
Lei Zhang4f261ff2018-10-10 18:44:45 +0000218 if (sValue.has_value() && fieldType == FormFieldType::kComboBox)
219 pWidget->ResetAppearance(sValue, false);
jaepark8c541822016-08-30 13:43:05 -0700220 }
221
222#ifdef PDF_ENABLE_XFA
223 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
dsinclair521b7502016-11-02 13:02:28 -0700224 CPDFXFA_Context* pContext = pPageView->GetFormFillEnv()->GetXFAContext();
Ryan Harrison854d71c2017-10-18 12:28:14 -0400225 if (pContext->GetFormType() == FormType::kXFAForeground) {
jaepark8c541822016-08-30 13:43:05 -0700226 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
Lei Zhange858d1f2019-07-29 23:43:41 +0000227 pWidget->ResetXFAAppearance(false);
jaepark8c541822016-08-30 13:43:05 -0700228 }
229#endif // PDF_ENABLE_XFA
jaepark8c541822016-08-30 13:43:05 -0700230}
231
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000232bool CPDFSDK_WidgetHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700233 uint32_t nFlag) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000234 return (*pAnnot)->IsSignatureWidget() ||
235 m_pFormFiller->OnSetFocus(pAnnot, nFlag);
jaepark8c541822016-08-30 13:43:05 -0700236}
237
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000238bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
tsepez4cf55152016-11-02 14:37:54 -0700239 uint32_t nFlag) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000240 return (*pAnnot)->IsSignatureWidget() ||
241 m_pFormFiller->OnKillFocus(pAnnot, nFlag);
jaepark8c541822016-08-30 13:43:05 -0700242}
243
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000244bool CPDFSDK_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000245 int index,
246 bool selected) {
247 return !(*pAnnot)->IsSignatureWidget() &&
248 m_pFormFiller->SetIndexSelected(pAnnot, index, selected);
249}
250
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000251bool CPDFSDK_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
rycsmitha5230e22019-02-21 17:33:03 +0000252 int index) {
253 return !(*pAnnot)->IsSignatureWidget() &&
254 m_pFormFiller->IsIndexSelected(pAnnot, index);
255}
256
jaepark8c541822016-08-30 13:43:05 -0700257#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700258bool CPDFSDK_WidgetHandler::OnXFAChangedFocus(
Tom Sepezd8ae8f82019-06-12 17:58:33 +0000259 ObservedPtr<CPDFSDK_Annot>* pOldAnnot,
260 ObservedPtr<CPDFSDK_Annot>* pNewAnnot) {
tsepez4cf55152016-11-02 14:37:54 -0700261 return true;
jaepark8c541822016-08-30 13:43:05 -0700262}
263#endif // PDF_ENABLE_XFA
264
265CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
266 CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000267 if (!pAnnot->IsSignatureWidget())
jaepark8c541822016-08-30 13:43:05 -0700268 return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot));
Lei Zhangd24236a2017-06-29 18:28:58 -0700269 return CFX_FloatRect();
jaepark8c541822016-08-30 13:43:05 -0700270}
271
Lei Zhanga4c7ac42018-04-17 15:12:58 +0000272WideString CPDFSDK_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000273 if (!pAnnot->IsSignatureWidget())
Lei Zhanga4c7ac42018-04-17 15:12:58 +0000274 return m_pFormFiller->GetText(pAnnot);
275 return WideString();
276}
277
Ryan Harrison275e2602017-09-18 14:23:18 -0400278WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000279 if (!pAnnot->IsSignatureWidget())
Diana Gagedce2d722017-06-20 11:17:11 -0700280 return m_pFormFiller->GetSelectedText(pAnnot);
Ryan Harrison275e2602017-09-18 14:23:18 -0400281 return WideString();
Diana Gagedce2d722017-06-20 11:17:11 -0700282}
283
Diana Gageab390972017-07-28 17:07:39 -0700284void CPDFSDK_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot,
Ryan Harrison275e2602017-09-18 14:23:18 -0400285 const WideString& text) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000286 if (!pAnnot->IsSignatureWidget())
Diana Gageab390972017-07-28 17:07:39 -0700287 m_pFormFiller->ReplaceSelection(pAnnot, text);
Diana Gage1c7f1422017-07-24 11:19:52 -0700288}
289
Lei Zhangee967722018-04-19 20:55:54 +0000290bool CPDFSDK_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000291 return !pAnnot->IsSignatureWidget() && m_pFormFiller->CanUndo(pAnnot);
Lei Zhangee967722018-04-19 20:55:54 +0000292}
293
294bool CPDFSDK_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000295 return !pAnnot->IsSignatureWidget() && m_pFormFiller->CanRedo(pAnnot);
Lei Zhangee967722018-04-19 20:55:54 +0000296}
297
298bool CPDFSDK_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000299 return !pAnnot->IsSignatureWidget() && m_pFormFiller->Undo(pAnnot);
Lei Zhangee967722018-04-19 20:55:54 +0000300}
301
302bool CPDFSDK_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
Lei Zhang7db136a2018-10-10 21:34:17 +0000303 return !pAnnot->IsSignatureWidget() && m_pFormFiller->Redo(pAnnot);
Lei Zhangee967722018-04-19 20:55:54 +0000304}
305
tsepez4cf55152016-11-02 14:37:54 -0700306bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
307 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500308 const CFX_PointF& point) {
jaepark8c541822016-08-30 13:43:05 -0700309 ASSERT(pPageView);
310 ASSERT(pAnnot);
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500311 return GetViewBBox(pPageView, pAnnot).Contains(point);
jaepark8c541822016-08-30 13:43:05 -0700312}