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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 ASSERT(pAnnot != NULL); | 391 ASSERT(pAnnot != NULL); |
392 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 392 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
393 | 393 |
394 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 394 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
395 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); | 395 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
396 } | 396 } |
397 | 397 |
398 return FALSE; | 398 return FALSE; |
399 } | 399 } |
400 | 400 |
401 FX_BOOL CFFL_IFormFiller::OnRButtonDblClk(CPDFSDK_PageView* pPageView, | |
402 CPDFSDK_Annot* pAnnot, | |
403 FX_UINT nFlags, | |
404 const CPDF_Point& point) { | |
405 ASSERT(pAnnot != NULL); | |
406 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
407 | |
408 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | |
409 return pFormFiller->OnRButtonDblClk(pPageView, pAnnot, nFlags, point); | |
410 } | |
411 | |
412 return FALSE; | |
413 } | |
414 | |
415 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 401 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
416 FX_UINT nKeyCode, | 402 FX_UINT nKeyCode, |
417 FX_UINT nFlags) { | 403 FX_UINT nFlags) { |
418 ASSERT(pAnnot != NULL); | 404 ASSERT(pAnnot != NULL); |
419 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 405 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
420 | 406 |
421 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 407 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
422 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); | 408 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); |
423 } | 409 } |
424 | 410 |
425 return FALSE; | 411 return FALSE; |
426 } | 412 } |
427 | 413 |
428 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 414 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
429 FX_UINT nChar, | 415 FX_UINT nChar, |
430 FX_UINT nFlags) { | 416 FX_UINT nFlags) { |
431 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 417 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
432 if (nChar == FWL_VKEY_Tab) | 418 if (nChar == FWL_VKEY_Tab) |
433 return TRUE; | 419 return TRUE; |
434 | 420 |
435 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 421 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
436 return pFormFiller->OnChar(pAnnot, nChar, nFlags); | 422 return pFormFiller->OnChar(pAnnot, nChar, nFlags); |
437 | 423 |
438 return FALSE; | 424 return FALSE; |
439 } | 425 } |
440 | 426 |
441 void CFFL_IFormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot) { | |
442 ASSERT(pAnnot != NULL); | |
443 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
444 | |
445 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | |
446 pFormFiller->OnDeSelected(pAnnot); | |
447 } | |
448 } | |
449 | |
450 void CFFL_IFormFiller::OnSelected(CPDFSDK_Annot* pAnnot) { | |
451 ASSERT(pAnnot != NULL); | |
452 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
453 | |
454 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | |
455 pFormFiller->OnSelected(pAnnot); | |
456 } | |
457 } | |
458 | |
459 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 427 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
460 if (!pAnnot) | 428 if (!pAnnot) |
461 return FALSE; | 429 return FALSE; |
462 | 430 |
463 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 431 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
464 | 432 |
465 if (!m_bNotifying) { | 433 if (!m_bNotifying) { |
466 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 434 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
467 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) { | 435 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) { |
468 m_bNotifying = TRUE; | 436 m_bNotifying = TRUE; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 577 |
610 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { | 578 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { |
611 auto it = m_Maps.find(pAnnot); | 579 auto it = m_Maps.find(pAnnot); |
612 if (it == m_Maps.end()) | 580 if (it == m_Maps.end()) |
613 return; | 581 return; |
614 | 582 |
615 delete it->second; | 583 delete it->second; |
616 m_Maps.erase(it); | 584 m_Maps.erase(it); |
617 } | 585 } |
618 | 586 |
619 void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, | |
620 FX_BOOL bSameField, | |
621 FX_BOOL bNext) {} | |
622 | |
623 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, | 587 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, |
624 FX_FLOAT fPopupMin, | 588 FX_FLOAT fPopupMin, |
625 FX_FLOAT fPopupMax, | 589 FX_FLOAT fPopupMax, |
626 int32_t& nRet, | 590 int32_t& nRet, |
627 FX_FLOAT& fPopupRet) { | 591 FX_FLOAT& fPopupRet) { |
628 ASSERT(pPrivateData != NULL); | 592 ASSERT(pPrivateData != NULL); |
629 | 593 |
630 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 594 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
631 | 595 |
632 CPDF_Rect rcPageView(0, 0, 0, 0); | 596 CPDF_Rect rcPageView(0, 0, 0, 0); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 fFactHeight = fBottom; | 652 fFactHeight = fBottom; |
689 bBottom = TRUE; | 653 bBottom = TRUE; |
690 } | 654 } |
691 } | 655 } |
692 } | 656 } |
693 | 657 |
694 nRet = bBottom ? 0 : 1; | 658 nRet = bBottom ? 0 : 1; |
695 fPopupRet = fFactHeight; | 659 fPopupRet = fFactHeight; |
696 } | 660 } |
697 | 661 |
698 void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, | |
699 const CPDF_Rect& rcWindow) { | |
700 ASSERT(pPrivateData != NULL); | |
701 | |
702 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | |
703 | |
704 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, TRUE)) { | |
705 CPDF_Rect rcOld = | |
706 pFormFiller->PWLtoFFL(pFormFiller->GetWindowRect(pData->pPageView)); | |
707 CPDF_Rect rcNew = pFormFiller->PWLtoFFL(rcWindow); | |
708 pFormFiller->SetWindowRect(pData->pPageView, rcWindow); | |
709 | |
710 CPDF_Rect unRect = rcOld; | |
711 unRect.Union(rcNew); | |
712 // FX_RECT rcRect = unRect.GetOutterRect(); | |
713 unRect.left = (FX_FLOAT)(unRect.left - 0.5); | |
714 unRect.right = (FX_FLOAT)(unRect.right + 0.5); | |
715 unRect.top = (FX_FLOAT)(unRect.top + 0.5); | |
716 unRect.bottom = (FX_FLOAT)(unRect.bottom - 0.5); | |
717 m_pApp->FFI_Invalidate(pData->pWidget->GetPDFXFAPage(), unRect.left, | |
718 unRect.top, unRect.right, unRect.bottom); | |
719 } | |
720 } | |
721 | |
722 void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, | |
723 void* pPrivateData, | |
724 int32_t nKeyCode, | |
725 CFX_WideString& strChange, | |
726 const CFX_WideString& strChangeEx, | |
727 FX_BOOL bKeyDown, | |
728 FX_BOOL& bRC, | |
729 FX_BOOL& bExit) { | |
730 ASSERT(pPrivateData != NULL); | |
731 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | |
732 ASSERT(pData->pWidget != NULL); | |
733 | |
734 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | |
735 ASSERT(pFormFiller != NULL); | |
736 | |
737 pFormFiller->OnKeyStroke(bKeyDown); | |
738 } | |
739 | |
740 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, | 662 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, |
741 CPDFSDK_PageView* pPageView, | 663 CPDFSDK_PageView* pPageView, |
742 FX_BOOL& bRC, | 664 FX_BOOL& bRC, |
743 FX_BOOL& bExit, | 665 FX_BOOL& bExit, |
744 FX_DWORD nFlag) { | 666 FX_DWORD nFlag) { |
745 if (!m_bNotifying) { | 667 if (!m_bNotifying) { |
746 ASSERT(pWidget != NULL); | 668 ASSERT(pWidget != NULL); |
747 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) { | 669 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) { |
748 m_bNotifying = TRUE; | 670 m_bNotifying = TRUE; |
749 pWidget->ClearAppModified(); | 671 pWidget->ClearAppModified(); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 } | 980 } |
1059 | 981 |
1060 FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, | 982 FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, |
1061 CPDFSDK_Annot* pAnnot) { | 983 CPDFSDK_Annot* pAnnot) { |
1062 if (pPageView) | 984 if (pPageView) |
1063 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); | 985 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); |
1064 | 986 |
1065 return FALSE; | 987 return FALSE; |
1066 } | 988 } |
1067 | 989 |
1068 void CFFL_IFormFiller::BeforeUndo(CPDFSDK_Document* pDocument) {} | |
1069 | |
1070 void CFFL_IFormFiller::BeforeRedo(CPDFSDK_Document* pDocument) { | |
1071 BeforeUndo(pDocument); | |
1072 } | |
1073 | |
1074 void CFFL_IFormFiller::AfterUndo(CPDFSDK_Document* pDocument) {} | |
1075 | |
1076 void CFFL_IFormFiller::AfterRedo(CPDFSDK_Document* pDocument) {} | |
1077 | |
1078 FX_BOOL CFFL_IFormFiller::CanCopy(CPDFSDK_Document* pDocument) { | |
1079 return FALSE; | |
1080 } | |
1081 | |
1082 FX_BOOL CFFL_IFormFiller::CanCut(CPDFSDK_Document* pDocument) { | |
1083 return FALSE; | |
1084 } | |
1085 | |
1086 FX_BOOL CFFL_IFormFiller::CanPaste(CPDFSDK_Document* pDocument) { | |
1087 return FALSE; | |
1088 } | |
1089 | |
1090 void CFFL_IFormFiller::DoCopy(CPDFSDK_Document* pDocument) {} | |
1091 | |
1092 void CFFL_IFormFiller::DoCut(CPDFSDK_Document* pDocument) {} | |
1093 | |
1094 void CFFL_IFormFiller::DoPaste(CPDFSDK_Document* pDocument) {} | |
1095 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, | 990 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, |
1096 void* pPrivateData, | 991 void* pPrivateData, |
1097 int32_t nKeyCode, | 992 int32_t nKeyCode, |
1098 CFX_WideString& strChange, | 993 CFX_WideString& strChange, |
1099 const CFX_WideString& strChangeEx, | 994 const CFX_WideString& strChangeEx, |
1100 int nSelStart, | 995 int nSelStart, |
1101 int nSelEnd, | 996 int nSelEnd, |
1102 FX_BOOL bKeyDown, | 997 FX_BOOL bKeyDown, |
1103 FX_BOOL& bRC, | 998 FX_BOOL& bRC, |
1104 FX_BOOL& bExit, | 999 FX_BOOL& bExit, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 ASSERT(pPrivateData != NULL); | 1087 ASSERT(pPrivateData != NULL); |
1193 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 1088 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
1194 ASSERT(pData->pWidget != NULL); | 1089 ASSERT(pData->pWidget != NULL); |
1195 | 1090 |
1196 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 1091 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
1197 ASSERT(pFormFiller != NULL); | 1092 ASSERT(pFormFiller != NULL); |
1198 | 1093 |
1199 if (!bEditOrList) | 1094 if (!bEditOrList) |
1200 pFormFiller->OnKeyStroke(bExit); | 1095 pFormFiller->OnKeyStroke(bExit); |
1201 } | 1096 } |
OLD | NEW |