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