Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: fpdfsdk/formfiller/cffl_interactiveformfiller.cpp

Issue 2368403002: Watch destruction of widgets around OnAAction() method (Closed)
Patch Set: Pass everywhere Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" 7 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) { 117 void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {
118 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 118 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
119 pFormFiller->OnDelete(pAnnot); 119 pFormFiller->OnDelete(pAnnot);
120 } 120 }
121 121
122 UnRegisterFormFiller(pAnnot); 122 UnRegisterFormFiller(pAnnot);
123 } 123 }
124 124
125 void CFFL_InteractiveFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, 125 void CFFL_InteractiveFormFiller::OnMouseEnter(
126 CPDFSDK_Annot* pAnnot, 126 CPDFSDK_PageView* pPageView,
127 uint32_t nFlag) { 127 CPDFSDK_Annot::ObservedPtr& pAnnot,
128 uint32_t nFlag) {
128 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 129 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
129
130 if (!m_bNotifying) { 130 if (!m_bNotifying) {
131 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 131 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
132 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) { 132 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) {
133 m_bNotifying = TRUE; 133 m_bNotifying = TRUE;
134 134
135 int nValueAge = pWidget->GetValueAge(); 135 int nValueAge = pWidget->GetValueAge();
136
137 pWidget->ClearAppModified(); 136 pWidget->ClearAppModified();
138
139 ASSERT(pPageView); 137 ASSERT(pPageView);
140 138
141 PDFSDK_FieldAction fa; 139 PDFSDK_FieldAction fa;
142 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 140 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
143 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 141 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
144 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); 142 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView);
145 m_bNotifying = FALSE; 143 m_bNotifying = FALSE;
144 if (!pAnnot)
145 return;
146 146
147 if (pWidget->IsAppModified()) { 147 if (pWidget->IsAppModified()) {
148 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { 148 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
149 pFormFiller->ResetPDFWindow(pPageView, 149 pFormFiller->ResetPDFWindow(pPageView,
150 pWidget->GetValueAge() == nValueAge); 150 pWidget->GetValueAge() == nValueAge);
151 } 151 }
152 } 152 }
153 } 153 }
154 } 154 }
155 155 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), TRUE))
156 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { 156 pFormFiller->OnMouseEnter(pPageView, pAnnot.Get());
157 pFormFiller->OnMouseEnter(pPageView, pAnnot);
158 }
159 } 157 }
160 158
161 void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, 159 void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
162 CPDFSDK_Annot* pAnnot, 160 CPDFSDK_Annot::ObservedPtr& pAnnot,
163 uint32_t nFlag) { 161 uint32_t nFlag) {
164 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 162 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
165
166 if (!m_bNotifying) { 163 if (!m_bNotifying) {
167 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 164 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
168 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) { 165 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) {
169 m_bNotifying = TRUE; 166 m_bNotifying = TRUE;
170 pWidget->GetAppearanceAge(); 167 pWidget->GetAppearanceAge();
168
171 int nValueAge = pWidget->GetValueAge(); 169 int nValueAge = pWidget->GetValueAge();
172 pWidget->ClearAppModified(); 170 pWidget->ClearAppModified();
173
174 ASSERT(pPageView); 171 ASSERT(pPageView);
175 172
176 PDFSDK_FieldAction fa; 173 PDFSDK_FieldAction fa;
177 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 174 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
178 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 175 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
179
180 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); 176 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
181 m_bNotifying = FALSE; 177 m_bNotifying = FALSE;
178 if (!pAnnot)
179 return;
182 180
183 if (pWidget->IsAppModified()) { 181 if (pWidget->IsAppModified()) {
184 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { 182 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
185 pFormFiller->ResetPDFWindow(pPageView, 183 pFormFiller->ResetPDFWindow(pPageView,
186 nValueAge == pWidget->GetValueAge()); 184 nValueAge == pWidget->GetValueAge());
187 } 185 }
188 } 186 }
189 } 187 }
190 } 188 }
191 189 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE))
192 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 190 pFormFiller->OnMouseExit(pPageView, pAnnot.Get());
193 pFormFiller->OnMouseExit(pPageView, pAnnot);
194 }
195 } 191 }
196 192
197 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, 193 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDown(
198 CPDFSDK_Annot* pAnnot, 194 CPDFSDK_PageView* pPageView,
199 uint32_t nFlags, 195 CPDFSDK_Annot::ObservedPtr& pAnnot,
200 const CFX_FloatPoint& point) { 196 uint32_t nFlags,
197 const CFX_FloatPoint& point) {
201 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 198 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
202
203 if (!m_bNotifying) { 199 if (!m_bNotifying) {
204 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 200 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
205 if (Annot_HitTest(pPageView, pAnnot, point) && 201 if (Annot_HitTest(pPageView, pAnnot.Get(), point) &&
206 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) { 202 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) {
207 m_bNotifying = TRUE; 203 m_bNotifying = TRUE;
208 pWidget->GetAppearanceAge(); 204 pWidget->GetAppearanceAge();
205
209 int nValueAge = pWidget->GetValueAge(); 206 int nValueAge = pWidget->GetValueAge();
210 pWidget->ClearAppModified(); 207 pWidget->ClearAppModified();
211
212 ASSERT(pPageView); 208 ASSERT(pPageView);
213 209
214 PDFSDK_FieldAction fa; 210 PDFSDK_FieldAction fa;
215 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlags); 211 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlags);
216 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlags); 212 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlags);
217 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); 213 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);
218 m_bNotifying = FALSE; 214 m_bNotifying = FALSE;
215 if (!pAnnot)
216 return TRUE;
219 217
220 if (!IsValidAnnot(pPageView, pAnnot)) 218 if (!IsValidAnnot(pPageView, pAnnot.Get()))
221 return TRUE; 219 return TRUE;
222 220
223 if (pWidget->IsAppModified()) { 221 if (pWidget->IsAppModified()) {
224 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { 222 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
225 pFormFiller->ResetPDFWindow(pPageView, 223 pFormFiller->ResetPDFWindow(pPageView,
226 nValueAge == pWidget->GetValueAge()); 224 nValueAge == pWidget->GetValueAge());
227 } 225 }
228 } 226 }
229 } 227 }
230 } 228 }
231 229 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE))
232 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 230 return pFormFiller->OnLButtonDown(pPageView, pAnnot.Get(), nFlags, point);
233 return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
234 }
235 231
236 return FALSE; 232 return FALSE;
237 } 233 }
238 234
239 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, 235 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonUp(
240 CPDFSDK_Annot* pAnnot, 236 CPDFSDK_PageView* pPageView,
241 uint32_t nFlags, 237 CPDFSDK_Annot::ObservedPtr& pAnnot,
242 const CFX_FloatPoint& point) { 238 uint32_t nFlags,
239 const CFX_FloatPoint& point) {
243 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 240 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
244 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 241 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
245 CPDFSDK_Document* pDocument = m_pEnv->GetSDKDocument(); 242 CPDFSDK_Document* pDocument = m_pEnv->GetSDKDocument();
246 243
247 switch (pWidget->GetFieldType()) { 244 switch (pWidget->GetFieldType()) {
248 case FIELDTYPE_PUSHBUTTON: 245 case FIELDTYPE_PUSHBUTTON:
249 case FIELDTYPE_CHECKBOX: 246 case FIELDTYPE_CHECKBOX:
250 case FIELDTYPE_RADIOBUTTON: 247 case FIELDTYPE_RADIOBUTTON:
251 if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y)) 248 if (GetViewBBox(pPageView, pAnnot.Get())
249 .Contains((int)point.x, (int)point.y))
252 pDocument->SetFocusAnnot(pAnnot); 250 pDocument->SetFocusAnnot(pAnnot);
253 break; 251 break;
254 default: 252 default:
255 pDocument->SetFocusAnnot(pAnnot); 253 pDocument->SetFocusAnnot(pAnnot);
256 break; 254 break;
257 } 255 }
258 256
259 FX_BOOL bRet = FALSE; 257 FX_BOOL bRet = FALSE;
260 258
261 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 259 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE)) {
262 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); 260 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot.Get(), nFlags, point);
263 } 261 }
264 262
265 if (pDocument->GetFocusAnnot() == pAnnot) { 263 if (pDocument->GetFocusAnnot() == pAnnot.Get()) {
266 FX_BOOL bExit = FALSE; 264 FX_BOOL bExit = FALSE;
267 FX_BOOL bReset = FALSE; 265 FX_BOOL bReset = FALSE;
268 OnButtonUp(pWidget, pPageView, bReset, bExit, nFlags); 266 OnButtonUp(pAnnot, pPageView, bReset, bExit, nFlags);
267 if (!pAnnot)
268 bExit = TRUE;
269 if (bExit) 269 if (bExit)
270 return TRUE; 270 return TRUE;
271 #ifdef PDF_ENABLE_XFA 271 #ifdef PDF_ENABLE_XFA
272 OnClick(pWidget, pPageView, bReset, bExit, nFlags); 272 OnClick(pWidget, pPageView, bReset, bExit, nFlags);
273 if (!pAnnot)
274 bExit = TRUE;
273 if (bExit) 275 if (bExit)
274 return TRUE; 276 return TRUE;
275 #endif // PDF_ENABLE_XFA 277 #endif // PDF_ENABLE_XFA
276 } 278 }
277 return bRet; 279 return bRet;
278 } 280 }
279 281
280 void CFFL_InteractiveFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, 282 void CFFL_InteractiveFormFiller::OnButtonUp(CPDFSDK_Annot::ObservedPtr& pAnnot,
281 CPDFSDK_PageView* pPageView, 283 CPDFSDK_PageView* pPageView,
282 FX_BOOL& bReset, 284 FX_BOOL& bReset,
283 FX_BOOL& bExit, 285 FX_BOOL& bExit,
284 uint32_t nFlag) { 286 uint32_t nFlag) {
285 ASSERT(pWidget);
286
287 if (!m_bNotifying) { 287 if (!m_bNotifying) {
288 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
288 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) { 289 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) {
289 m_bNotifying = TRUE; 290 m_bNotifying = TRUE;
291
290 int nAge = pWidget->GetAppearanceAge(); 292 int nAge = pWidget->GetAppearanceAge();
291 int nValueAge = pWidget->GetValueAge(); 293 int nValueAge = pWidget->GetValueAge();
292
293 ASSERT(pPageView); 294 ASSERT(pPageView);
294 295
295 PDFSDK_FieldAction fa; 296 PDFSDK_FieldAction fa;
296 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 297 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
297 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 298 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
298
299 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); 299 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
300 m_bNotifying = FALSE; 300 m_bNotifying = FALSE;
301 301 if (!pAnnot || !IsValidAnnot(pPageView, pWidget)) {
302 if (!IsValidAnnot(pPageView, pWidget)) {
303 bExit = TRUE; 302 bExit = TRUE;
304 return; 303 return;
305 } 304 }
306
307 if (nAge != pWidget->GetAppearanceAge()) { 305 if (nAge != pWidget->GetAppearanceAge()) {
308 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { 306 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
309 pFormFiller->ResetPDFWindow(pPageView, 307 pFormFiller->ResetPDFWindow(pPageView,
310 nValueAge == pWidget->GetValueAge()); 308 nValueAge == pWidget->GetValueAge());
311 } 309 }
312
313 bReset = TRUE; 310 bReset = TRUE;
314 } 311 }
315 } 312 }
316 } 313 }
317 } 314 }
318 315
319 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDblClk( 316 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDblClk(
320 CPDFSDK_PageView* pPageView, 317 CPDFSDK_PageView* pPageView,
321 CPDFSDK_Annot* pAnnot, 318 CPDFSDK_Annot::ObservedPtr& pAnnot,
322 uint32_t nFlags, 319 uint32_t nFlags,
323 const CFX_FloatPoint& point) { 320 const CFX_FloatPoint& point) {
324 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 321 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
325 322 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE);
326 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 323 return pFormFiller &&
327 return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); 324 pFormFiller->OnLButtonDblClk(pPageView, pAnnot.Get(), nFlags, point);
328 }
329
330 return FALSE;
331 } 325 }
332 326
333 FX_BOOL CFFL_InteractiveFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, 327 FX_BOOL CFFL_InteractiveFormFiller::OnMouseMove(
334 CPDFSDK_Annot* pAnnot, 328 CPDFSDK_PageView* pPageView,
335 uint32_t nFlags, 329 CPDFSDK_Annot::ObservedPtr& pAnnot,
336 const CFX_FloatPoint& point) { 330 uint32_t nFlags,
331 const CFX_FloatPoint& point) {
337 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 332 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
338 333 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), TRUE);
339 // change cursor 334 return pFormFiller &&
340 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { 335 pFormFiller->OnMouseMove(pPageView, pAnnot.Get(), nFlags, point);
341 return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
342 }
343
344 return FALSE;
345 } 336 }
346 337
347 FX_BOOL CFFL_InteractiveFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, 338 FX_BOOL CFFL_InteractiveFormFiller::OnMouseWheel(
348 CPDFSDK_Annot* pAnnot, 339 CPDFSDK_PageView* pPageView,
349 uint32_t nFlags, 340 CPDFSDK_Annot::ObservedPtr& pAnnot,
350 short zDelta, 341 uint32_t nFlags,
351 const CFX_FloatPoint& point) { 342 short zDelta,
343 const CFX_FloatPoint& point) {
352 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 344 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
353 345 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE);
354 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 346 return pFormFiller &&
355 return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); 347 pFormFiller->OnMouseWheel(pPageView, pAnnot.Get(), nFlags, zDelta,
356 } 348 point);
357
358 return FALSE;
359 } 349 }
360 350
361 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, 351 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonDown(
362 CPDFSDK_Annot* pAnnot, 352 CPDFSDK_PageView* pPageView,
363 uint32_t nFlags, 353 CPDFSDK_Annot::ObservedPtr& pAnnot,
364 const CFX_FloatPoint& point) { 354 uint32_t nFlags,
355 const CFX_FloatPoint& point) {
365 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 356 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
366 357 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE);
367 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 358 return pFormFiller &&
368 return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); 359 pFormFiller->OnRButtonDown(pPageView, pAnnot.Get(), nFlags, point);
369 }
370
371 return FALSE;
372 } 360 }
373 361
374 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, 362 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonUp(
375 CPDFSDK_Annot* pAnnot, 363 CPDFSDK_PageView* pPageView,
376 uint32_t nFlags, 364 CPDFSDK_Annot::ObservedPtr& pAnnot,
377 const CFX_FloatPoint& point) { 365 uint32_t nFlags,
366 const CFX_FloatPoint& point) {
378 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 367 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
379 368 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE);
380 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 369 return pFormFiller &&
381 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); 370 pFormFiller->OnRButtonUp(pPageView, pAnnot.Get(), nFlags, point);
382 }
383
384 return FALSE;
385 } 371 }
386 372
387 FX_BOOL CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, 373 FX_BOOL CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
388 uint32_t nKeyCode, 374 uint32_t nKeyCode,
389 uint32_t nFlags) { 375 uint32_t nFlags) {
390 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 376 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
391 377
392 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 378 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
393 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); 379 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
394 } 380 }
395 381
396 return FALSE; 382 return FALSE;
397 } 383 }
398 384
399 FX_BOOL CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot, 385 FX_BOOL CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
400 uint32_t nChar, 386 uint32_t nChar,
401 uint32_t nFlags) { 387 uint32_t nFlags) {
402 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 388 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
403 if (nChar == FWL_VKEY_Tab) 389 if (nChar == FWL_VKEY_Tab)
404 return TRUE; 390 return TRUE;
405 391
406 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) 392 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
407 return pFormFiller->OnChar(pAnnot, nChar, nFlags); 393 return pFormFiller->OnChar(pAnnot, nChar, nFlags);
408 394
409 return FALSE; 395 return FALSE;
410 } 396 }
411 397
412 FX_BOOL CFFL_InteractiveFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, 398 FX_BOOL CFFL_InteractiveFormFiller::OnSetFocus(
413 uint32_t nFlag) { 399 CPDFSDK_Annot::ObservedPtr& pAnnot,
400 uint32_t nFlag) {
414 if (!pAnnot) 401 if (!pAnnot)
415 return FALSE; 402 return FALSE;
416 403
417 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 404 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
418
419 if (!m_bNotifying) { 405 if (!m_bNotifying) {
420 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 406 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
421 if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) { 407 if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) {
422 m_bNotifying = TRUE; 408 m_bNotifying = TRUE;
423 pWidget->GetAppearanceAge(); 409 pWidget->GetAppearanceAge();
424 410
425 int nValueAge = pWidget->GetValueAge(); 411 int nValueAge = pWidget->GetValueAge();
426 pWidget->ClearAppModified(); 412 pWidget->ClearAppModified();
427 413
414 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
415 if (!pFormFiller)
416 return FALSE;
417
428 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 418 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
429 ASSERT(pPageView); 419 ASSERT(pPageView);
430 420
431 PDFSDK_FieldAction fa; 421 PDFSDK_FieldAction fa;
432 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 422 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
433 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 423 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
434
435 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
436 if (!pFormFiller)
437 return FALSE;
438 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); 424 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
439 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); 425 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);
440 m_bNotifying = FALSE; 426 m_bNotifying = FALSE;
427 if (!pAnnot)
428 return FALSE;
441 429
442 if (pWidget->IsAppModified()) { 430 if (pWidget->IsAppModified()) {
443 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) { 431 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) {
444 pFiller->ResetPDFWindow(pPageView, 432 pFiller->ResetPDFWindow(pPageView,
445 nValueAge == pWidget->GetValueAge()); 433 nValueAge == pWidget->GetValueAge());
446 } 434 }
447 } 435 }
448 } 436 }
449 } 437 }
450 438
451 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) 439 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), TRUE))
452 pFormFiller->SetFocusForAnnot(pAnnot, nFlag); 440 pFormFiller->SetFocusForAnnot(pAnnot.Get(), nFlag);
453 441
454 return TRUE; 442 return TRUE;
455 } 443 }
456 444
457 FX_BOOL CFFL_InteractiveFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, 445 FX_BOOL CFFL_InteractiveFormFiller::OnKillFocus(
458 uint32_t nFlag) { 446 CPDFSDK_Annot::ObservedPtr& pAnnot,
447 uint32_t nFlag) {
459 if (!pAnnot) 448 if (!pAnnot)
460 return FALSE; 449 return FALSE;
450
461 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); 451 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
462 452 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot.Get(), FALSE)) {
463 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 453 pFormFiller->KillFocusForAnnot(pAnnot.Get(), nFlag);
464 pFormFiller->KillFocusForAnnot(pAnnot, nFlag);
465
466 if (!m_bNotifying) { 454 if (!m_bNotifying) {
467 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 455 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
468 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) { 456 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) {
469 m_bNotifying = TRUE; 457 m_bNotifying = TRUE;
470 pWidget->ClearAppModified(); 458 pWidget->ClearAppModified();
471 459
472 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); 460 CPDFSDK_PageView* pPageView = pWidget->GetPageView();
473 ASSERT(pPageView); 461 ASSERT(pPageView);
474 462
475 PDFSDK_FieldAction fa; 463 PDFSDK_FieldAction fa;
476 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 464 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
477 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 465 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
478
479 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); 466 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
480
481 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); 467 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
482 m_bNotifying = FALSE; 468 m_bNotifying = FALSE;
469 if (!pAnnot)
470 return FALSE;
483 } 471 }
484 } 472 }
485 } 473 }
486
487 return TRUE; 474 return TRUE;
488 } 475 }
489 476
490 FX_BOOL CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) { 477 FX_BOOL CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) {
491 return pWidget->IsVisible(); 478 return pWidget->IsVisible();
492 } 479 }
493 480
494 FX_BOOL CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) { 481 FX_BOOL CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) {
495 int nFieldFlags = pWidget->GetFieldFlags(); 482 int nFieldFlags = pWidget->GetFieldFlags();
496 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY; 483 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 fFactHeight = fBottom; 620 fFactHeight = fBottom;
634 bBottom = TRUE; 621 bBottom = TRUE;
635 } 622 }
636 } 623 }
637 } 624 }
638 625
639 nRet = bBottom ? 0 : 1; 626 nRet = bBottom ? 0 : 1;
640 fPopupRet = fFactHeight; 627 fPopupRet = fFactHeight;
641 } 628 }
642 629
643 void CFFL_InteractiveFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, 630 void CFFL_InteractiveFormFiller::OnKeyStrokeCommit(
644 CPDFSDK_PageView* pPageView, 631 CPDFSDK_Annot::ObservedPtr& pAnnot,
645 FX_BOOL& bRC, 632 CPDFSDK_PageView* pPageView,
646 FX_BOOL& bExit, 633 FX_BOOL& bRC,
647 uint32_t nFlag) { 634 FX_BOOL& bExit,
635 uint32_t nFlag) {
648 if (!m_bNotifying) { 636 if (!m_bNotifying) {
637 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
649 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { 638 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
639 ASSERT(pPageView);
650 m_bNotifying = TRUE; 640 m_bNotifying = TRUE;
651 pWidget->ClearAppModified(); 641 pWidget->ClearAppModified();
652 642
653 ASSERT(pPageView);
654
655 PDFSDK_FieldAction fa; 643 PDFSDK_FieldAction fa;
656 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 644 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
657 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 645 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
658 fa.bWillCommit = TRUE; 646 fa.bWillCommit = TRUE;
659 fa.bKeyDown = TRUE; 647 fa.bKeyDown = TRUE;
660 fa.bRC = TRUE; 648 fa.bRC = TRUE;
661 649
662 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); 650 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
663 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); 651 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
664 pFormFiller->SaveState(pPageView); 652 pFormFiller->SaveState(pPageView);
665
666 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); 653 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
654 if (!pAnnot)
655 return;
667 656
668 bRC = fa.bRC; 657 bRC = fa.bRC;
669 m_bNotifying = FALSE; 658 m_bNotifying = FALSE;
670 } 659 }
671 } 660 }
672 } 661 }
673 662
674 void CFFL_InteractiveFormFiller::OnValidate(CPDFSDK_Widget* pWidget, 663 void CFFL_InteractiveFormFiller::OnValidate(CPDFSDK_Annot::ObservedPtr& pAnnot,
675 CPDFSDK_PageView* pPageView, 664 CPDFSDK_PageView* pPageView,
676 FX_BOOL& bRC, 665 FX_BOOL& bRC,
677 FX_BOOL& bExit, 666 FX_BOOL& bExit,
678 uint32_t nFlag) { 667 uint32_t nFlag) {
679 if (!m_bNotifying) { 668 if (!m_bNotifying) {
669 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
680 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) { 670 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) {
671 ASSERT(pPageView);
681 m_bNotifying = TRUE; 672 m_bNotifying = TRUE;
682 pWidget->ClearAppModified(); 673 pWidget->ClearAppModified();
683 674
684 ASSERT(pPageView);
685
686 PDFSDK_FieldAction fa; 675 PDFSDK_FieldAction fa;
687 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); 676 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag);
688 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); 677 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag);
689 fa.bKeyDown = TRUE; 678 fa.bKeyDown = TRUE;
690 fa.bRC = TRUE; 679 fa.bRC = TRUE;
691 680
692 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); 681 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
693 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); 682 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
694 pFormFiller->SaveState(pPageView); 683 pFormFiller->SaveState(pPageView);
695
696 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); 684 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
685 if (!pAnnot)
686 return;
697 687
698 bRC = fa.bRC; 688 bRC = fa.bRC;
699 m_bNotifying = FALSE; 689 m_bNotifying = FALSE;
700 } 690 }
701 } 691 }
702 } 692 }
703 693
704 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, 694 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget,
705 CPDFSDK_PageView* pPageView, 695 CPDFSDK_PageView* pPageView,
706 FX_BOOL& bExit, 696 FX_BOOL& bExit,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 898
909 bReset = TRUE; 899 bReset = TRUE;
910 } 900 }
911 } 901 }
912 } 902 }
913 } 903 }
914 #endif // PDF_ENABLE_XFA 904 #endif // PDF_ENABLE_XFA
915 905
916 FX_BOOL CFFL_InteractiveFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, 906 FX_BOOL CFFL_InteractiveFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView,
917 CPDFSDK_Annot* pAnnot) { 907 CPDFSDK_Annot* pAnnot) {
918 if (pPageView) 908 return pPageView && pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
919 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
920
921 return FALSE;
922 } 909 }
923 910
924 void CFFL_InteractiveFormFiller::OnBeforeKeyStroke( 911 void CFFL_InteractiveFormFiller::OnBeforeKeyStroke(
925 void* pPrivateData, 912 void* pPrivateData,
926 CFX_WideString& strChange, 913 CFX_WideString& strChange,
927 const CFX_WideString& strChangeEx, 914 const CFX_WideString& strChangeEx,
928 int nSelStart, 915 int nSelStart,
929 int nSelEnd, 916 int nSelEnd,
930 FX_BOOL bKeyDown, 917 FX_BOOL bKeyDown,
931 FX_BOOL& bRC, 918 FX_BOOL& bRC,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 fa.sChangeEx = strChangeEx; 951 fa.sChangeEx = strChangeEx;
965 fa.bKeyDown = bKeyDown; 952 fa.bKeyDown = bKeyDown;
966 fa.bWillCommit = FALSE; 953 fa.bWillCommit = FALSE;
967 fa.bRC = TRUE; 954 fa.bRC = TRUE;
968 fa.nSelStart = nSelStart; 955 fa.nSelStart = nSelStart;
969 fa.nSelEnd = nSelEnd; 956 fa.nSelEnd = nSelEnd;
970 957
971 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); 958 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
972 pFormFiller->SaveState(pData->pPageView); 959 pFormFiller->SaveState(pData->pPageView);
973 960
961 CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget);
974 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, 962 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa,
975 pData->pPageView)) { 963 pData->pPageView)) {
976 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { 964 if (!pObserved || !IsValidAnnot(pData->pPageView, pData->pWidget)) {
977 bExit = TRUE; 965 bExit = TRUE;
978 m_bNotifying = FALSE; 966 m_bNotifying = FALSE;
979 return; 967 return;
980 } 968 }
981 969
982 if (nAge != pData->pWidget->GetAppearanceAge()) { 970 if (nAge != pData->pWidget->GetAppearanceAge()) {
983 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( 971 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(
984 pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); 972 pData->pPageView, nValueAge == pData->pWidget->GetValueAge());
985 pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); 973 pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
986 bExit = TRUE; 974 bExit = TRUE;
(...skipping 17 matching lines...) Expand all
1004 bExit = TRUE; 992 bExit = TRUE;
1005 m_bNotifying = FALSE; 993 m_bNotifying = FALSE;
1006 return; 994 return;
1007 } 995 }
1008 } 996 }
1009 997
1010 m_bNotifying = FALSE; 998 m_bNotifying = FALSE;
1011 } 999 }
1012 } 1000 }
1013 } 1001 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698