jaepark | 8c54182 | 2016-08-30 13:43:05 -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 | #include "fpdfsdk/cpdfsdk_widgethandler.h" |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 8 | |
| 9 | #include <memory> |
| 10 | #include <vector> |
| 11 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 12 | #include "core/fpdfapi/page/cpdf_page.h" |
dsinclair | 488b7ad | 2016-10-04 11:55:50 -0700 | [diff] [blame] | 13 | #include "core/fpdfapi/parser/cpdf_document.h" |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 14 | #include "core/fpdfdoc/cpdf_interform.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 15 | #include "fpdfsdk/cpdfsdk_annot.h" |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 17 | #include "fpdfsdk/cpdfsdk_interform.h" |
| 18 | #include "fpdfsdk/cpdfsdk_pageview.h" |
| 19 | #include "fpdfsdk/cpdfsdk_widget.h" |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 20 | #include "fpdfsdk/formfiller/cffl_formfiller.h" |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 21 | |
| 22 | #ifdef PDF_ENABLE_XFA |
dsinclair | 521b750 | 2016-11-02 13:02:28 -0700 | [diff] [blame] | 23 | #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 24 | #endif // PDF_ENABLE_XFA |
| 25 | |
dsinclair | 8779fa8 | 2016-10-12 12:05:44 -0700 | [diff] [blame] | 26 | CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler( |
| 27 | CPDFSDK_FormFillEnvironment* pFormFillEnv) |
| 28 | : m_pFormFillEnv(pFormFillEnv), m_pFormFiller(nullptr) {} |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 29 | |
| 30 | CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {} |
| 31 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 32 | bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 33 | ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 34 | if (pAnnot->IsSignatureWidget()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 35 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 36 | |
| 37 | CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
| 38 | if (!pWidget->IsVisible()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 39 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 40 | |
| 41 | int nFieldFlags = pWidget->GetFieldFlags(); |
| 42 | if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 43 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 44 | |
| 45 | if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 46 | return true; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 47 | |
| 48 | CPDF_Page* pPage = pWidget->GetPDFPage(); |
| 49 | CPDF_Document* pDocument = pPage->m_pDocument; |
| 50 | uint32_t dwPermissions = pDocument->GetUserPermissions(); |
| 51 | return (dwPermissions & FPDFPERM_FILL_FORM) || |
| 52 | (dwPermissions & FPDFPERM_ANNOT_FORM); |
| 53 | } |
| 54 | |
| 55 | CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, |
| 56 | CPDFSDK_PageView* pPage) { |
dsinclair | 8779fa8 | 2016-10-12 12:05:44 -0700 | [diff] [blame] | 57 | CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 58 | CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( |
| 59 | pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); |
| 60 | if (!pCtrl) |
| 61 | return nullptr; |
| 62 | |
| 63 | CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
| 64 | pInterForm->AddMap(pCtrl, pWidget); |
| 65 | CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 66 | if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 67 | pWidget->ResetAppearance(nullptr, false); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 68 | |
| 69 | return pWidget; |
| 70 | } |
| 71 | |
| 72 | #ifdef PDF_ENABLE_XFA |
| 73 | CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CXFA_FFWidget* hWidget, |
| 74 | CPDFSDK_PageView* pPage) { |
| 75 | return nullptr; |
| 76 | } |
| 77 | #endif // PDF_ENABLE_XFA |
| 78 | |
| 79 | void CPDFSDK_WidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
| 80 | ASSERT(pAnnot); |
| 81 | |
| 82 | if (m_pFormFiller) |
| 83 | m_pFormFiller->OnDelete(pAnnot); |
| 84 | |
| 85 | std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot)); |
| 86 | CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
| 87 | CPDF_FormControl* pControl = pWidget->GetFormControl(); |
| 88 | pInterForm->RemoveMap(pControl); |
| 89 | } |
| 90 | |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 91 | void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, |
| 92 | CPDFSDK_Annot* pAnnot, |
| 93 | CFX_RenderDevice* pDevice, |
jaepark | 75f84a5 | 2016-09-09 15:39:09 -0700 | [diff] [blame] | 94 | CFX_Matrix* pUser2Device, |
| 95 | bool bDrawAnnots) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 96 | if (pAnnot->IsSignatureWidget()) { |
| 97 | static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( |
| 98 | pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 99 | } else { |
| 100 | if (m_pFormFiller) |
jaepark | 4bae296 | 2016-09-01 14:39:24 -0700 | [diff] [blame] | 101 | m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 105 | void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 106 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 107 | uint32_t nFlag) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 108 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 109 | m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); |
| 110 | } |
| 111 | |
| 112 | void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 113 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 114 | uint32_t nFlag) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 115 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 116 | m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); |
| 117 | } |
| 118 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 119 | bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 120 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 121 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 122 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 123 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 124 | return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
| 125 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 126 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 127 | } |
| 128 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 129 | bool CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 130 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 131 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 132 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 133 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 134 | return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
| 135 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 136 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 137 | } |
| 138 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 139 | bool CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 140 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 141 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 142 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 143 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 144 | return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
| 145 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 146 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 147 | } |
| 148 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 149 | bool CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 150 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 151 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 152 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 153 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 154 | return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
| 155 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 156 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 157 | } |
| 158 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 159 | bool CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 160 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 161 | uint32_t nFlags, |
| 162 | short zDelta, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 163 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 164 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 165 | return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
| 166 | point); |
| 167 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 168 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 169 | } |
| 170 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 171 | bool CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 172 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 173 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 174 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 175 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 176 | return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
| 177 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 178 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 179 | } |
| 180 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 181 | bool CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 182 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 183 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 184 | const CFX_PointF& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 185 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 186 | return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
| 187 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 188 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 189 | } |
| 190 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 191 | bool CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
| 192 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 193 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 194 | const CFX_PointF& point) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 195 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 196 | } |
| 197 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 198 | bool CPDFSDK_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, |
| 199 | uint32_t nChar, |
| 200 | uint32_t nFlags) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 201 | if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
| 202 | return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); |
| 203 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 204 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 205 | } |
| 206 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 207 | bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 208 | int nKeyCode, |
| 209 | int nFlag) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 210 | if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
| 211 | return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 212 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 213 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 214 | } |
| 215 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 216 | bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 217 | int nKeyCode, |
| 218 | int nFlag) { |
| 219 | return false; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 220 | } |
| 221 | |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 222 | void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) { |
| 223 | if (pAnnot->IsSignatureWidget()) |
| 224 | return; |
| 225 | |
| 226 | CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
| 227 | if (!pWidget->IsAppearanceValid()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 228 | pWidget->ResetAppearance(nullptr, false); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 229 | |
| 230 | int nFieldType = pWidget->GetFieldType(); |
| 231 | if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 232 | bool bFormatted = false; |
tsepez | 8c2a8cd | 2016-09-07 15:29:11 -0700 | [diff] [blame] | 233 | CFX_WideString sValue = pWidget->OnFormat(bFormatted); |
| 234 | if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 235 | pWidget->ResetAppearance(&sValue, false); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | #ifdef PDF_ENABLE_XFA |
| 239 | CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
dsinclair | 521b750 | 2016-11-02 13:02:28 -0700 | [diff] [blame] | 240 | CPDFXFA_Context* pContext = pPageView->GetFormFillEnv()->GetXFAContext(); |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 241 | if (pContext->GetDocType() == XFA_DocType::Static) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 242 | if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 243 | pWidget->ResetAppearance(false); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 244 | } |
| 245 | #endif // PDF_ENABLE_XFA |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 246 | } |
| 247 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 248 | bool CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 249 | uint32_t nFlag) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 250 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 251 | return m_pFormFiller->OnSetFocus(pAnnot, nFlag); |
| 252 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 253 | return true; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 254 | } |
| 255 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 256 | bool CPDFSDK_WidgetHandler::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 257 | uint32_t nFlag) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 258 | if (!(*pAnnot)->IsSignatureWidget() && m_pFormFiller) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 259 | return m_pFormFiller->OnKillFocus(pAnnot, nFlag); |
| 260 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 261 | return true; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | #ifdef PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 265 | bool CPDFSDK_WidgetHandler::OnXFAChangedFocus( |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 266 | CPDFSDK_Annot::ObservedPtr* pOldAnnot, |
| 267 | CPDFSDK_Annot::ObservedPtr* pNewAnnot) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 268 | return true; |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 269 | } |
| 270 | #endif // PDF_ENABLE_XFA |
| 271 | |
| 272 | CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 273 | CPDFSDK_Annot* pAnnot) { |
| 274 | if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
| 275 | return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot)); |
| 276 | |
| 277 | return CFX_FloatRect(0, 0, 0, 0); |
| 278 | } |
| 279 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 280 | bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, |
| 281 | CPDFSDK_Annot* pAnnot, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 282 | const CFX_PointF& point) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 283 | ASSERT(pPageView); |
| 284 | ASSERT(pAnnot); |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 285 | return GetViewBBox(pPageView, pAnnot).Contains(point); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 286 | } |