OLD | NEW |
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 "../../include/formfiller/FFL_FormFiller.h" | 7 #include "../../include/formfiller/FFL_FormFiller.h" |
8 #include "../../include/formfiller/FFL_IFormFiller.h" | 8 #include "../../include/formfiller/FFL_IFormFiller.h" |
9 #include "../../include/formfiller/FFL_CheckBox.h" | 9 #include "../../include/formfiller/FFL_CheckBox.h" |
10 #include "../../include/formfiller/FFL_ComboBox.h" | 10 #include "../../include/formfiller/FFL_ComboBox.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 { | 37 { |
38 CPDF_Rect rc = pAnnot->GetRect(); | 38 CPDF_Rect rc = pAnnot->GetRect(); |
39 if(rc.Contains(point.x, point.y)) | 39 if(rc.Contains(point.x, point.y)) |
40 return TRUE; | 40 return TRUE; |
41 return FALSE; | 41 return FALSE; |
42 } | 42 } |
43 | 43 |
44 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot) | 44 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot) |
45 { | 45 { |
46 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 46 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
47 { | |
48 return pFormFiller->GetViewBBox(pPageView, pAnnot); | 47 return pFormFiller->GetViewBBox(pPageView, pAnnot); |
49 } | |
50 else | |
51 { | |
52 ASSERT(pPageView != NULL); | |
53 ASSERT(pAnnot != NULL); | |
54 | 48 |
55 » » CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 49 ASSERT(pPageView != NULL); |
56 » » ASSERT(pPDFAnnot != NULL); | |
57 | 50 |
58 » » CPDF_Rect rcAnnot; | 51 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
59 » » pPDFAnnot->GetRect(rcAnnot); | 52 CPDF_Rect rcAnnot; |
| 53 pPDFAnnot->GetRect(rcAnnot); |
60 | 54 |
61 // » » CRect rcWin; | 55 CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); |
62 // » » pPageView->DocToWindow(rcAnnot, rcWin); | 56 return rcWin.GetOutterRect(); |
63 » » CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot,1); | |
64 //» » rcWin.InflateRect(1, 1); | |
65 | |
66 » » return rcWin.GetOutterRect(); | |
67 » } | |
68 } | 57 } |
69 | 58 |
70 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
Annot* pAnnot, | 59 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
Annot* pAnnot, |
71 CFX_RenderDevice* pDevice, CPDF_
Matrix* pUser2Device, | 60 CFX_RenderDevice* pDevice, CPDF_
Matrix* pUser2Device, |
72 /*const CRect& rcWindow,*/ FX_DW
ORD dwFlags) | 61 /*const CRect& rcWindow,*/ FX_DW
ORD dwFlags) |
73 { | 62 { |
74 ASSERT(pPageView != NULL); | 63 ASSERT(pPageView != NULL); |
75 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 64 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
76 | 65 |
77 if (IsVisible(pWidget)) | 66 if (IsVisible(pWidget)) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 421 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
433 { | 422 { |
434 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); | 423 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); |
435 } | 424 } |
436 | 425 |
437 return FALSE; | 426 return FALSE; |
438 } | 427 } |
439 | 428 |
440 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n
Flags) | 429 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n
Flags) |
441 { | 430 { |
442 ASSERT(pAnnot != NULL); | |
443 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 431 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
444 | 432 » if (nChar == FWL_VKEY_Tab) |
445 » if (nChar == FWL_VKEY_Tab) return TRUE; | 433 return TRUE; |
446 | 434 |
447 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 435 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
448 { | |
449 return pFormFiller->OnChar(pAnnot, nChar, nFlags); | 436 return pFormFiller->OnChar(pAnnot, nChar, nFlags); |
450 } | |
451 | 437 |
452 return FALSE; | 438 return FALSE; |
453 } | 439 } |
454 | 440 |
455 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 441 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) |
456 { | 442 { |
457 » if(!pAnnot) return FALSE; | 443 » if (!pAnnot) |
| 444 return FALSE; |
| 445 |
458 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 446 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
459 | 447 |
460 if (!m_bNotifying) | 448 if (!m_bNotifying) |
461 { | 449 { |
462 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 450 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
463 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) | 451 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) |
464 { | 452 { |
465 m_bNotifying = TRUE; | 453 m_bNotifying = TRUE; |
466 pWidget->GetAppearanceAge(); | 454 pWidget->GetAppearanceAge(); |
| 455 |
467 int nValueAge = pWidget->GetValueAge(); | 456 int nValueAge = pWidget->GetValueAge(); |
468 pWidget->ClearAppModified(); | 457 pWidget->ClearAppModified(); |
469 | 458 |
470 | |
471 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 459 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
472 ASSERT(pPageView != NULL); | 460 ASSERT(pPageView != NULL); |
473 | 461 |
474 PDFSDK_FieldAction fa; | 462 PDFSDK_FieldAction fa; |
475 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 463 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
476 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 464 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
477 | 465 |
478 | |
479 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TR
UE); | 466 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TR
UE); |
480 if(!pFormFiller) return FALSE; | 467 if(!pFormFiller) return FALSE; |
481 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetF
ocus, fa); | 468 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetF
ocus, fa); |
482 | |
483 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView
); | 469 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView
); |
484 m_bNotifying = FALSE; | 470 m_bNotifying = FALSE; |
485 | 471 |
486 // if (!IsValidAnnot(m_pApp, pDocument, pDocView, pPageView
, pAnnot)) return FALSE; | |
487 | |
488 if (pWidget->IsAppModified()) | 472 if (pWidget->IsAppModified()) |
489 { | 473 { |
490 if (CFFL_FormFiller* pFormFiller = GetFormFiller
(pWidget, FALSE)) | 474 if (CFFL_FormFiller* pFormFiller = GetFormFiller
(pWidget, FALSE)) |
491 { | 475 { |
492 pFormFiller->ResetPDFWindow(pPageView, n
ValueAge == pWidget->GetValueAge()); | 476 pFormFiller->ResetPDFWindow(pPageView, n
ValueAge == pWidget->GetValueAge()); |
493 } | 477 } |
494 } | 478 } |
495 } | 479 } |
496 } | 480 } |
497 | 481 |
498 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) | 482 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) |
499 » { | 483 » » return pFormFiller->OnSetFocus(pAnnot, nFlag); |
500 » » if (pFormFiller->OnSetFocus(pAnnot, nFlag)) | |
501 » » { | |
502 » » » return TRUE; | |
503 » » } | |
504 » » else | |
505 » » » return FALSE; | |
506 » } | |
507 | 484 |
508 return TRUE; | 485 return TRUE; |
509 } | 486 } |
510 | 487 |
511 FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 488 FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) |
512 { | 489 { |
513 if(!pAnnot) return FALSE; | 490 if(!pAnnot) return FALSE; |
514 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 491 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
515 | 492 |
516 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 493 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 ASSERT(pPrivateData != NULL); | 944 ASSERT(pPrivateData != NULL); |
968 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 945 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
969 ASSERT(pData->pWidget != NULL); | 946 ASSERT(pData->pWidget != NULL); |
970 | 947 |
971 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 948 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
972 ASSERT(pFormFiller != NULL); | 949 ASSERT(pFormFiller != NULL); |
973 | 950 |
974 if (!bEditOrList) | 951 if (!bEditOrList) |
975 pFormFiller->OnKeyStroke(bExit); | 952 pFormFiller->OnKeyStroke(bExit); |
976 } | 953 } |
OLD | NEW |