blob: 5e258bc4e564d60fdb0f3961381802ec64f2cc1f [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_xfawidgethandler.h"
jaepark98e10192016-08-15 10:51:11 -07008
dsinclair1727aee2016-09-29 13:12:56 -07009#include "core/fpdfdoc/cpdf_interform.h"
dsinclair114e46a2016-09-29 17:18:21 -070010#include "fpdfsdk/cpdfsdk_annot.h"
dsinclair735606d2016-10-05 15:47:02 -070011#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
dsinclair114e46a2016-09-29 17:18:21 -070012#include "fpdfsdk/cpdfsdk_interform.h"
13#include "fpdfsdk/cpdfsdk_pageview.h"
14#include "fpdfsdk/cpdfsdk_xfawidget.h"
dsinclair521b7502016-11-02 13:02:28 -070015#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
dsinclair447b1f32016-12-08 10:06:32 -080016#include "xfa/fwl/cfwl_app.h"
17#include "xfa/fwl/fwl_widgethit.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040018#include "xfa/fxfa/cxfa_ffdocview.h"
19#include "xfa/fxfa/cxfa_ffpageview.h"
20#include "xfa/fxfa/cxfa_ffwidget.h"
21#include "xfa/fxfa/cxfa_ffwidgethandler.h"
dsinclair5b493092016-09-29 20:20:24 -070022#include "xfa/fxfa/fxfa_basic.h"
dsinclair202ad722016-09-29 17:41:42 -070023#include "xfa/fxgraphics/cfx_graphics.h"
jaepark98e10192016-08-15 10:51:11 -070024
dsinclair735606d2016-10-05 15:47:02 -070025CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler(
dsinclair8779fa82016-10-12 12:05:44 -070026 CPDFSDK_FormFillEnvironment* pFormFillEnv)
27 : m_pFormFillEnv(pFormFillEnv) {}
jaepark98e10192016-08-15 10:51:11 -070028
jaepark8c541822016-08-30 13:43:05 -070029CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {}
jaepark98e10192016-08-15 10:51:11 -070030
tsepez4cf55152016-11-02 14:37:54 -070031bool CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
jaepark98e10192016-08-15 10:51:11 -070032 return !!pAnnot->GetXFAWidget();
33}
34
jaepark8c541822016-08-30 13:43:05 -070035CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CPDF_Annot* pAnnot,
36 CPDFSDK_PageView* pPage) {
jaepark98e10192016-08-15 10:51:11 -070037 return nullptr;
38}
39
jaepark8c541822016-08-30 13:43:05 -070040CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CXFA_FFWidget* pAnnot,
41 CPDFSDK_PageView* pPage) {
dsinclair8779fa82016-10-12 12:05:44 -070042 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
jaepark98e10192016-08-15 10:51:11 -070043 CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm);
44 pInterForm->AddXFAMap(pAnnot, pWidget);
45 return pWidget;
46}
47
jaepark8c541822016-08-30 13:43:05 -070048void CPDFSDK_XFAWidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
49 CPDFSDK_Annot* pAnnot,
50 CFX_RenderDevice* pDevice,
jaepark75f84a52016-09-09 15:39:09 -070051 CFX_Matrix* pUser2Device,
52 bool bDrawAnnots) {
jaepark98e10192016-08-15 10:51:11 -070053 ASSERT(pPageView);
54 ASSERT(pAnnot);
55
Dan Sinclairb9c69ab2017-02-23 13:30:34 -050056 CFX_Graphics gs(pDevice);
jaepark98e10192016-08-15 10:51:11 -070057
Dan Sinclairbba2a7c2017-02-07 16:36:39 -050058 CFX_Matrix mt = *pUser2Device;
tsepez4cf55152016-11-02 14:37:54 -070059 bool bIsHighlight = false;
dsinclair7cbe68e2016-10-12 11:56:23 -070060 if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot)
tsepez4cf55152016-11-02 14:37:54 -070061 bIsHighlight = true;
jaepark98e10192016-08-15 10:51:11 -070062
dsinclairb402b172016-10-11 09:26:32 -070063 GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt,
64 bIsHighlight);
jaepark98e10192016-08-15 10:51:11 -070065
66 // to do highlight and shadow
67}
68
jaepark8c541822016-08-30 13:43:05 -070069void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {}
jaepark98e10192016-08-15 10:51:11 -070070
jaepark8c541822016-08-30 13:43:05 -070071void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
jaepark98e10192016-08-15 10:51:11 -070072 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot);
73 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
74 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget());
75
76 delete pWidget;
77}
78
jaepark8c541822016-08-30 13:43:05 -070079CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
80 CPDFSDK_Annot* pAnnot) {
jaepark98e10192016-08-15 10:51:11 -070081 ASSERT(pAnnot);
82
83 CFX_RectF rcBBox;
84 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType();
85 if (eType == XFA_Element::Signature)
Dan Sinclair1b08df12017-02-09 09:17:20 -050086 rcBBox = pAnnot->GetXFAWidget()->GetBBox(XFA_WidgetStatus_Visible, true);
jaepark98e10192016-08-15 10:51:11 -070087 else
Dan Sinclair1b08df12017-02-09 09:17:20 -050088 rcBBox = pAnnot->GetXFAWidget()->GetBBox(XFA_WidgetStatus_None);
jaepark98e10192016-08-15 10:51:11 -070089
90 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
91 rcBBox.top + rcBBox.height);
92 rcWidget.left -= 1.0f;
93 rcWidget.right += 1.0f;
94 rcWidget.bottom -= 1.0f;
95 rcWidget.top += 1.0f;
96
97 return rcWidget;
98}
99
tsepez4cf55152016-11-02 14:37:54 -0700100bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
101 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500102 const CFX_PointF& point) {
jaepark98e10192016-08-15 10:51:11 -0700103 if (!pPageView || !pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700104 return false;
jaepark98e10192016-08-15 10:51:11 -0700105
dsinclairb402b172016-10-11 09:26:32 -0700106 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
dsinclair7cbe68e2016-10-12 11:56:23 -0700107 if (!pFormFillEnv)
tsepez4cf55152016-11-02 14:37:54 -0700108 return false;
jaepark98e10192016-08-15 10:51:11 -0700109
dsinclair521b7502016-11-02 13:02:28 -0700110 CPDFXFA_Context* pContext = pFormFillEnv->GetXFAContext();
111 if (!pContext)
tsepez4cf55152016-11-02 14:37:54 -0700112 return false;
jaepark98e10192016-08-15 10:51:11 -0700113
dsinclair521b7502016-11-02 13:02:28 -0700114 CXFA_FFDocView* pDocView = pContext->GetXFADocView();
jaepark98e10192016-08-15 10:51:11 -0700115 if (!pDocView)
tsepez4cf55152016-11-02 14:37:54 -0700116 return false;
jaepark98e10192016-08-15 10:51:11 -0700117
118 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
119 if (!pWidgetHandler)
tsepez4cf55152016-11-02 14:37:54 -0700120 return false;
jaepark98e10192016-08-15 10:51:11 -0700121
122 FWL_WidgetHit dwHitTest =
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500123 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point);
jaepark98e10192016-08-15 10:51:11 -0700124 return dwHitTest != FWL_WidgetHit::Unknown;
125}
126
jaepark8c541822016-08-30 13:43:05 -0700127void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -0700128 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700129 uint32_t nFlag) {
tsepezf8074ce2016-09-27 14:29:57 -0700130 if (!pPageView || !(*pAnnot))
jaepark98e10192016-08-15 10:51:11 -0700131 return;
tsepezf8074ce2016-09-27 14:29:57 -0700132 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
133 pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget());
jaepark98e10192016-08-15 10:51:11 -0700134}
135
jaepark8c541822016-08-30 13:43:05 -0700136void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -0700137 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700138 uint32_t nFlag) {
tsepezf8074ce2016-09-27 14:29:57 -0700139 if (!pPageView || !(*pAnnot))
jaepark98e10192016-08-15 10:51:11 -0700140 return;
141
tsepezf8074ce2016-09-27 14:29:57 -0700142 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
143 pWidgetHandler->OnMouseExit((*pAnnot)->GetXFAWidget());
jaepark98e10192016-08-15 10:51:11 -0700144}
145
tsepez4cf55152016-11-02 14:37:54 -0700146bool CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
147 CPDFSDK_Annot::ObservedPtr* pAnnot,
148 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500149 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700150 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700151 return false;
jaepark98e10192016-08-15 10:51:11 -0700152
tsepezf8074ce2016-09-27 14:29:57 -0700153 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
154 return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500155 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700156}
157
tsepez4cf55152016-11-02 14:37:54 -0700158bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
159 CPDFSDK_Annot::ObservedPtr* pAnnot,
160 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500161 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700162 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700163 return false;
jaepark98e10192016-08-15 10:51:11 -0700164
tsepezf8074ce2016-09-27 14:29:57 -0700165 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
166 return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500167 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700168}
169
tsepez4cf55152016-11-02 14:37:54 -0700170bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk(
tsepezf8074ce2016-09-27 14:29:57 -0700171 CPDFSDK_PageView* pPageView,
172 CPDFSDK_Annot::ObservedPtr* pAnnot,
173 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500174 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700175 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700176 return false;
jaepark98e10192016-08-15 10:51:11 -0700177
tsepezf8074ce2016-09-27 14:29:57 -0700178 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
179 return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500180 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700181}
182
tsepez4cf55152016-11-02 14:37:54 -0700183bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
184 CPDFSDK_Annot::ObservedPtr* pAnnot,
185 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500186 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700187 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700188 return false;
jaepark98e10192016-08-15 10:51:11 -0700189
tsepezf8074ce2016-09-27 14:29:57 -0700190 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
191 return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500192 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700193}
194
tsepez4cf55152016-11-02 14:37:54 -0700195bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
196 CPDFSDK_Annot::ObservedPtr* pAnnot,
197 uint32_t nFlags,
198 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500199 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700200 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700201 return false;
jaepark98e10192016-08-15 10:51:11 -0700202
tsepezf8074ce2016-09-27 14:29:57 -0700203 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500204 return pWidgetHandler->OnMouseWheel((*pAnnot)->GetXFAWidget(),
205 GetFWLFlags(nFlags), zDelta, point);
jaepark98e10192016-08-15 10:51:11 -0700206}
207
tsepez4cf55152016-11-02 14:37:54 -0700208bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
209 CPDFSDK_Annot::ObservedPtr* pAnnot,
210 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500211 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700212 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700213 return false;
jaepark98e10192016-08-15 10:51:11 -0700214
tsepezf8074ce2016-09-27 14:29:57 -0700215 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
216 return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500217 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700218}
219
tsepez4cf55152016-11-02 14:37:54 -0700220bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
221 CPDFSDK_Annot::ObservedPtr* pAnnot,
222 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500223 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700224 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700225 return false;
jaepark98e10192016-08-15 10:51:11 -0700226
tsepezf8074ce2016-09-27 14:29:57 -0700227 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
228 return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500229 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700230}
231
tsepez4cf55152016-11-02 14:37:54 -0700232bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk(
tsepezf8074ce2016-09-27 14:29:57 -0700233 CPDFSDK_PageView* pPageView,
234 CPDFSDK_Annot::ObservedPtr* pAnnot,
235 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500236 const CFX_PointF& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700237 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700238 return false;
jaepark98e10192016-08-15 10:51:11 -0700239
tsepezf8074ce2016-09-27 14:29:57 -0700240 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
241 return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(),
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500242 GetFWLFlags(nFlags), point);
jaepark98e10192016-08-15 10:51:11 -0700243}
244
tsepez4cf55152016-11-02 14:37:54 -0700245bool CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
246 uint32_t nChar,
247 uint32_t nFlags) {
jaepark98e10192016-08-15 10:51:11 -0700248 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700249 return false;
jaepark98e10192016-08-15 10:51:11 -0700250
251 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
252 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar,
253 GetFWLFlags(nFlags));
254}
255
tsepez4cf55152016-11-02 14:37:54 -0700256bool CPDFSDK_XFAWidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
257 int nKeyCode,
258 int nFlag) {
jaepark98e10192016-08-15 10:51:11 -0700259 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700260 return false;
jaepark98e10192016-08-15 10:51:11 -0700261
262 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
263 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode,
264 GetFWLFlags(nFlag));
265}
266
tsepez4cf55152016-11-02 14:37:54 -0700267bool CPDFSDK_XFAWidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
268 int nKeyCode,
269 int nFlag) {
jaepark98e10192016-08-15 10:51:11 -0700270 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700271 return false;
jaepark98e10192016-08-15 10:51:11 -0700272
273 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
274 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode,
275 GetFWLFlags(nFlag));
276}
277
tsepez4cf55152016-11-02 14:37:54 -0700278bool CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
279 uint32_t nFlag) {
280 return true;
jaepark98e10192016-08-15 10:51:11 -0700281}
282
tsepez4cf55152016-11-02 14:37:54 -0700283bool CPDFSDK_XFAWidgetHandler::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
284 uint32_t nFlag) {
285 return true;
jaepark8c541822016-08-30 13:43:05 -0700286}
287
tsepez4cf55152016-11-02 14:37:54 -0700288bool CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus(
tsepezf8074ce2016-09-27 14:29:57 -0700289 CPDFSDK_Annot::ObservedPtr* pOldAnnot,
290 CPDFSDK_Annot::ObservedPtr* pNewAnnot) {
jaepark98e10192016-08-15 10:51:11 -0700291 CXFA_FFWidgetHandler* pWidgetHandler = nullptr;
tsepezf8074ce2016-09-27 14:29:57 -0700292 if (*pOldAnnot)
293 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get());
294 else if (*pNewAnnot)
295 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get());
jaepark98e10192016-08-15 10:51:11 -0700296
tsepezf8074ce2016-09-27 14:29:57 -0700297 if (!pWidgetHandler)
tsepez4cf55152016-11-02 14:37:54 -0700298 return true;
jaepark98e10192016-08-15 10:51:11 -0700299
tsepezf8074ce2016-09-27 14:29:57 -0700300 CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr;
301 if (!hWidget)
tsepez4cf55152016-11-02 14:37:54 -0700302 return true;
jaepark98e10192016-08-15 10:51:11 -0700303
tsepezf8074ce2016-09-27 14:29:57 -0700304 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
305 if (!pXFAPageView)
tsepez4cf55152016-11-02 14:37:54 -0700306 return true;
tsepezf8074ce2016-09-27 14:29:57 -0700307
tsepez4cf55152016-11-02 14:37:54 -0700308 bool bRet = pXFAPageView->GetDocView()->SetFocus(hWidget);
tsepezf8074ce2016-09-27 14:29:57 -0700309 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget)
tsepez4cf55152016-11-02 14:37:54 -0700310 bRet = true;
tsepezf8074ce2016-09-27 14:29:57 -0700311
312 return bRet;
jaepark98e10192016-08-15 10:51:11 -0700313}
314
jaepark8c541822016-08-30 13:43:05 -0700315CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler(
jaepark98e10192016-08-15 10:51:11 -0700316 CPDFSDK_Annot* pAnnot) {
317 if (!pAnnot)
318 return nullptr;
319
320 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
321 if (!pPageView)
322 return nullptr;
323
dsinclairb402b172016-10-11 09:26:32 -0700324 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
dsinclair7cbe68e2016-10-12 11:56:23 -0700325 if (!pFormFillEnv)
jaepark98e10192016-08-15 10:51:11 -0700326 return nullptr;
327
dsinclair521b7502016-11-02 13:02:28 -0700328 CPDFXFA_Context* pDoc = pFormFillEnv->GetXFAContext();
jaepark98e10192016-08-15 10:51:11 -0700329 if (!pDoc)
330 return nullptr;
331
332 CXFA_FFDocView* pDocView = pDoc->GetXFADocView();
333 if (!pDocView)
334 return nullptr;
335
336 return pDocView->GetWidgetHandler();
337}
338
jaepark8c541822016-08-30 13:43:05 -0700339uint32_t CPDFSDK_XFAWidgetHandler::GetFWLFlags(uint32_t dwFlag) {
jaepark98e10192016-08-15 10:51:11 -0700340 uint32_t dwFWLFlag = 0;
341
342 if (dwFlag & FWL_EVENTFLAG_ControlKey)
343 dwFWLFlag |= FWL_KEYFLAG_Ctrl;
344 if (dwFlag & FWL_EVENTFLAG_LeftButtonDown)
345 dwFWLFlag |= FWL_KEYFLAG_LButton;
346 if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown)
347 dwFWLFlag |= FWL_KEYFLAG_MButton;
348 if (dwFlag & FWL_EVENTFLAG_RightButtonDown)
349 dwFWLFlag |= FWL_KEYFLAG_RButton;
350 if (dwFlag & FWL_EVENTFLAG_ShiftKey)
351 dwFWLFlag |= FWL_KEYFLAG_Shift;
352 if (dwFlag & FWL_EVENTFLAG_AltKey)
353 dwFWLFlag |= FWL_KEYFLAG_Alt;
354
355 return dwFWLFlag;
356}