blob: 2401a6fefaec915f9d9bdf944aaa41348ca26087 [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"
dsinclair202ad722016-09-29 17:41:42 -070016#include "xfa/fwl/core/fwl_widgethit.h"
dsinclaira4060a32016-10-13 11:00:00 -070017#include "xfa/fwl/core/ifwl_app.h"
dsinclair5b493092016-09-29 20:20:24 -070018#include "xfa/fxfa/fxfa_basic.h"
19#include "xfa/fxfa/xfa_ffdocview.h"
20#include "xfa/fxfa/xfa_ffpageview.h"
21#include "xfa/fxfa/xfa_ffwidget.h"
22#include "xfa/fxfa/xfa_ffwidgethandler.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
jaepark98e10192016-08-15 10:51:11 -070056 CFX_Graphics gs;
57 gs.Create(pDevice);
58
59 CFX_Matrix mt;
60 mt = *pUser2Device;
61
tsepez4cf55152016-11-02 14:37:54 -070062 bool bIsHighlight = false;
dsinclair7cbe68e2016-10-12 11:56:23 -070063 if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot)
tsepez4cf55152016-11-02 14:37:54 -070064 bIsHighlight = true;
jaepark98e10192016-08-15 10:51:11 -070065
dsinclairb402b172016-10-11 09:26:32 -070066 GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt,
67 bIsHighlight);
jaepark98e10192016-08-15 10:51:11 -070068
69 // to do highlight and shadow
70}
71
jaepark8c541822016-08-30 13:43:05 -070072void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {}
jaepark98e10192016-08-15 10:51:11 -070073
jaepark8c541822016-08-30 13:43:05 -070074void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
jaepark98e10192016-08-15 10:51:11 -070075 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot);
76 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
77 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget());
78
79 delete pWidget;
80}
81
jaepark8c541822016-08-30 13:43:05 -070082CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
83 CPDFSDK_Annot* pAnnot) {
jaepark98e10192016-08-15 10:51:11 -070084 ASSERT(pAnnot);
85
86 CFX_RectF rcBBox;
87 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType();
88 if (eType == XFA_Element::Signature)
tsepez4cf55152016-11-02 14:37:54 -070089 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, true);
jaepark98e10192016-08-15 10:51:11 -070090 else
91 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None);
92
93 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
94 rcBBox.top + rcBBox.height);
95 rcWidget.left -= 1.0f;
96 rcWidget.right += 1.0f;
97 rcWidget.bottom -= 1.0f;
98 rcWidget.top += 1.0f;
99
100 return rcWidget;
101}
102
tsepez4cf55152016-11-02 14:37:54 -0700103bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
104 CPDFSDK_Annot* pAnnot,
105 const CFX_FloatPoint& point) {
jaepark98e10192016-08-15 10:51:11 -0700106 if (!pPageView || !pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700107 return false;
jaepark98e10192016-08-15 10:51:11 -0700108
dsinclairb402b172016-10-11 09:26:32 -0700109 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
dsinclair7cbe68e2016-10-12 11:56:23 -0700110 if (!pFormFillEnv)
tsepez4cf55152016-11-02 14:37:54 -0700111 return false;
jaepark98e10192016-08-15 10:51:11 -0700112
dsinclair521b7502016-11-02 13:02:28 -0700113 CPDFXFA_Context* pContext = pFormFillEnv->GetXFAContext();
114 if (!pContext)
tsepez4cf55152016-11-02 14:37:54 -0700115 return false;
jaepark98e10192016-08-15 10:51:11 -0700116
dsinclair521b7502016-11-02 13:02:28 -0700117 CXFA_FFDocView* pDocView = pContext->GetXFADocView();
jaepark98e10192016-08-15 10:51:11 -0700118 if (!pDocView)
tsepez4cf55152016-11-02 14:37:54 -0700119 return false;
jaepark98e10192016-08-15 10:51:11 -0700120
121 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
122 if (!pWidgetHandler)
tsepez4cf55152016-11-02 14:37:54 -0700123 return false;
jaepark98e10192016-08-15 10:51:11 -0700124
125 FWL_WidgetHit dwHitTest =
126 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y);
127 return dwHitTest != FWL_WidgetHit::Unknown;
128}
129
jaepark8c541822016-08-30 13:43:05 -0700130void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -0700131 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700132 uint32_t nFlag) {
tsepezf8074ce2016-09-27 14:29:57 -0700133 if (!pPageView || !(*pAnnot))
jaepark98e10192016-08-15 10:51:11 -0700134 return;
tsepezf8074ce2016-09-27 14:29:57 -0700135 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
136 pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget());
jaepark98e10192016-08-15 10:51:11 -0700137}
138
jaepark8c541822016-08-30 13:43:05 -0700139void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -0700140 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark8c541822016-08-30 13:43:05 -0700141 uint32_t nFlag) {
tsepezf8074ce2016-09-27 14:29:57 -0700142 if (!pPageView || !(*pAnnot))
jaepark98e10192016-08-15 10:51:11 -0700143 return;
144
tsepezf8074ce2016-09-27 14:29:57 -0700145 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
146 pWidgetHandler->OnMouseExit((*pAnnot)->GetXFAWidget());
jaepark98e10192016-08-15 10:51:11 -0700147}
148
tsepez4cf55152016-11-02 14:37:54 -0700149bool CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
150 CPDFSDK_Annot::ObservedPtr* pAnnot,
151 uint32_t nFlags,
152 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700153 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700154 return false;
jaepark98e10192016-08-15 10:51:11 -0700155
tsepezf8074ce2016-09-27 14:29:57 -0700156 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
157 return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700158 GetFWLFlags(nFlags), point.x, point.y);
159}
160
tsepez4cf55152016-11-02 14:37:54 -0700161bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
162 CPDFSDK_Annot::ObservedPtr* pAnnot,
163 uint32_t nFlags,
164 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700165 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700166 return false;
jaepark98e10192016-08-15 10:51:11 -0700167
tsepezf8074ce2016-09-27 14:29:57 -0700168 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
169 return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700170 GetFWLFlags(nFlags), point.x, point.y);
171}
172
tsepez4cf55152016-11-02 14:37:54 -0700173bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk(
tsepezf8074ce2016-09-27 14:29:57 -0700174 CPDFSDK_PageView* pPageView,
175 CPDFSDK_Annot::ObservedPtr* pAnnot,
176 uint32_t nFlags,
177 const CFX_FloatPoint& point) {
178 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700179 return false;
jaepark98e10192016-08-15 10:51:11 -0700180
tsepezf8074ce2016-09-27 14:29:57 -0700181 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
182 return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700183 GetFWLFlags(nFlags), point.x, point.y);
184}
185
tsepez4cf55152016-11-02 14:37:54 -0700186bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
187 CPDFSDK_Annot::ObservedPtr* pAnnot,
188 uint32_t nFlags,
189 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700190 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700191 return false;
jaepark98e10192016-08-15 10:51:11 -0700192
tsepezf8074ce2016-09-27 14:29:57 -0700193 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
194 return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700195 GetFWLFlags(nFlags), point.x, point.y);
196}
197
tsepez4cf55152016-11-02 14:37:54 -0700198bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
199 CPDFSDK_Annot::ObservedPtr* pAnnot,
200 uint32_t nFlags,
201 short zDelta,
202 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700203 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700204 return false;
jaepark98e10192016-08-15 10:51:11 -0700205
tsepezf8074ce2016-09-27 14:29:57 -0700206 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
jaepark98e10192016-08-15 10:51:11 -0700207 return pWidgetHandler->OnMouseWheel(
tsepezf8074ce2016-09-27 14:29:57 -0700208 (*pAnnot)->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y);
jaepark98e10192016-08-15 10:51:11 -0700209}
210
tsepez4cf55152016-11-02 14:37:54 -0700211bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
212 CPDFSDK_Annot::ObservedPtr* pAnnot,
213 uint32_t nFlags,
214 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700215 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700216 return false;
jaepark98e10192016-08-15 10:51:11 -0700217
tsepezf8074ce2016-09-27 14:29:57 -0700218 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
219 return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700220 GetFWLFlags(nFlags), point.x, point.y);
221}
222
tsepez4cf55152016-11-02 14:37:54 -0700223bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
224 CPDFSDK_Annot::ObservedPtr* pAnnot,
225 uint32_t nFlags,
226 const CFX_FloatPoint& point) {
tsepezf8074ce2016-09-27 14:29:57 -0700227 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700228 return false;
jaepark98e10192016-08-15 10:51:11 -0700229
tsepezf8074ce2016-09-27 14:29:57 -0700230 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
231 return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700232 GetFWLFlags(nFlags), point.x, point.y);
233}
234
tsepez4cf55152016-11-02 14:37:54 -0700235bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk(
tsepezf8074ce2016-09-27 14:29:57 -0700236 CPDFSDK_PageView* pPageView,
237 CPDFSDK_Annot::ObservedPtr* pAnnot,
238 uint32_t nFlags,
239 const CFX_FloatPoint& point) {
240 if (!pPageView || !(*pAnnot))
tsepez4cf55152016-11-02 14:37:54 -0700241 return false;
jaepark98e10192016-08-15 10:51:11 -0700242
tsepezf8074ce2016-09-27 14:29:57 -0700243 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
244 return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(),
jaepark98e10192016-08-15 10:51:11 -0700245 GetFWLFlags(nFlags), point.x, point.y);
246}
247
tsepez4cf55152016-11-02 14:37:54 -0700248bool CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
249 uint32_t nChar,
250 uint32_t nFlags) {
jaepark98e10192016-08-15 10:51:11 -0700251 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700252 return false;
jaepark98e10192016-08-15 10:51:11 -0700253
254 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
255 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar,
256 GetFWLFlags(nFlags));
257}
258
tsepez4cf55152016-11-02 14:37:54 -0700259bool CPDFSDK_XFAWidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
260 int nKeyCode,
261 int nFlag) {
jaepark98e10192016-08-15 10:51:11 -0700262 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700263 return false;
jaepark98e10192016-08-15 10:51:11 -0700264
265 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
266 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode,
267 GetFWLFlags(nFlag));
268}
269
tsepez4cf55152016-11-02 14:37:54 -0700270bool CPDFSDK_XFAWidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
271 int nKeyCode,
272 int nFlag) {
jaepark98e10192016-08-15 10:51:11 -0700273 if (!pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700274 return false;
jaepark98e10192016-08-15 10:51:11 -0700275
276 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
277 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode,
278 GetFWLFlags(nFlag));
279}
280
tsepez4cf55152016-11-02 14:37:54 -0700281bool CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
282 uint32_t nFlag) {
283 return true;
jaepark98e10192016-08-15 10:51:11 -0700284}
285
tsepez4cf55152016-11-02 14:37:54 -0700286bool CPDFSDK_XFAWidgetHandler::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
287 uint32_t nFlag) {
288 return true;
jaepark8c541822016-08-30 13:43:05 -0700289}
290
tsepez4cf55152016-11-02 14:37:54 -0700291bool CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus(
tsepezf8074ce2016-09-27 14:29:57 -0700292 CPDFSDK_Annot::ObservedPtr* pOldAnnot,
293 CPDFSDK_Annot::ObservedPtr* pNewAnnot) {
jaepark98e10192016-08-15 10:51:11 -0700294 CXFA_FFWidgetHandler* pWidgetHandler = nullptr;
tsepezf8074ce2016-09-27 14:29:57 -0700295 if (*pOldAnnot)
296 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get());
297 else if (*pNewAnnot)
298 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get());
jaepark98e10192016-08-15 10:51:11 -0700299
tsepezf8074ce2016-09-27 14:29:57 -0700300 if (!pWidgetHandler)
tsepez4cf55152016-11-02 14:37:54 -0700301 return true;
jaepark98e10192016-08-15 10:51:11 -0700302
tsepezf8074ce2016-09-27 14:29:57 -0700303 CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr;
304 if (!hWidget)
tsepez4cf55152016-11-02 14:37:54 -0700305 return true;
jaepark98e10192016-08-15 10:51:11 -0700306
tsepezf8074ce2016-09-27 14:29:57 -0700307 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
308 if (!pXFAPageView)
tsepez4cf55152016-11-02 14:37:54 -0700309 return true;
tsepezf8074ce2016-09-27 14:29:57 -0700310
tsepez4cf55152016-11-02 14:37:54 -0700311 bool bRet = pXFAPageView->GetDocView()->SetFocus(hWidget);
tsepezf8074ce2016-09-27 14:29:57 -0700312 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget)
tsepez4cf55152016-11-02 14:37:54 -0700313 bRet = true;
tsepezf8074ce2016-09-27 14:29:57 -0700314
315 return bRet;
jaepark98e10192016-08-15 10:51:11 -0700316}
317
jaepark8c541822016-08-30 13:43:05 -0700318CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler(
jaepark98e10192016-08-15 10:51:11 -0700319 CPDFSDK_Annot* pAnnot) {
320 if (!pAnnot)
321 return nullptr;
322
323 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
324 if (!pPageView)
325 return nullptr;
326
dsinclairb402b172016-10-11 09:26:32 -0700327 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
dsinclair7cbe68e2016-10-12 11:56:23 -0700328 if (!pFormFillEnv)
jaepark98e10192016-08-15 10:51:11 -0700329 return nullptr;
330
dsinclair521b7502016-11-02 13:02:28 -0700331 CPDFXFA_Context* pDoc = pFormFillEnv->GetXFAContext();
jaepark98e10192016-08-15 10:51:11 -0700332 if (!pDoc)
333 return nullptr;
334
335 CXFA_FFDocView* pDocView = pDoc->GetXFADocView();
336 if (!pDocView)
337 return nullptr;
338
339 return pDocView->GetWidgetHandler();
340}
341
jaepark8c541822016-08-30 13:43:05 -0700342uint32_t CPDFSDK_XFAWidgetHandler::GetFWLFlags(uint32_t dwFlag) {
jaepark98e10192016-08-15 10:51:11 -0700343 uint32_t dwFWLFlag = 0;
344
345 if (dwFlag & FWL_EVENTFLAG_ControlKey)
346 dwFWLFlag |= FWL_KEYFLAG_Ctrl;
347 if (dwFlag & FWL_EVENTFLAG_LeftButtonDown)
348 dwFWLFlag |= FWL_KEYFLAG_LButton;
349 if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown)
350 dwFWLFlag |= FWL_KEYFLAG_MButton;
351 if (dwFlag & FWL_EVENTFLAG_RightButtonDown)
352 dwFWLFlag |= FWL_KEYFLAG_RButton;
353 if (dwFlag & FWL_EVENTFLAG_ShiftKey)
354 dwFWLFlag |= FWL_KEYFLAG_Shift;
355 if (dwFlag & FWL_EVENTFLAG_AltKey)
356 dwFWLFlag |= FWL_KEYFLAG_Alt;
357
358 return dwFWLFlag;
359}