| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 436 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 437 | 437 |
| 438 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 438 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 439 { | 439 { |
| 440 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point
); | 440 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point
); |
| 441 } | 441 } |
| 442 | 442 |
| 443 return FALSE; | 443 return FALSE; |
| 444 } | 444 } |
| 445 | 445 |
| 446 FX_BOOL CFFL_IFormFiller::OnRButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_A
nnot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | |
| 447 { | |
| 448 ASSERT(pAnnot != NULL); | |
| 449 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 450 | |
| 451 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 452 { | |
| 453 return pFormFiller->OnRButtonDblClk(pPageView, pAnnot, nFlags, p
oint); | |
| 454 } | |
| 455 | |
| 456 return FALSE; | |
| 457 } | |
| 458 | |
| 459 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_
UINT nFlags) | 446 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_
UINT nFlags) |
| 460 { | 447 { |
| 461 ASSERT(pAnnot != NULL); | 448 ASSERT(pAnnot != NULL); |
| 462 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 449 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 463 | 450 |
| 464 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 451 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 465 { | 452 { |
| 466 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); | 453 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); |
| 467 } | 454 } |
| 468 | 455 |
| 469 return FALSE; | 456 return FALSE; |
| 470 } | 457 } |
| 471 | 458 |
| 472 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n
Flags) | 459 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n
Flags) |
| 473 { | 460 { |
| 474 ASSERT(pAnnot != NULL); | 461 ASSERT(pAnnot != NULL); |
| 475 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 462 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 476 | 463 |
| 477 if (nChar == FWL_VKEY_Tab) return TRUE; | 464 if (nChar == FWL_VKEY_Tab) return TRUE; |
| 478 | 465 |
| 479 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 466 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 480 { | 467 { |
| 481 return pFormFiller->OnChar(pAnnot, nChar, nFlags); | 468 return pFormFiller->OnChar(pAnnot, nChar, nFlags); |
| 482 } | 469 } |
| 483 | 470 |
| 484 return FALSE; | 471 return FALSE; |
| 485 } | 472 } |
| 486 | 473 |
| 487 void CFFL_IFormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot) | |
| 488 { | |
| 489 ASSERT(pAnnot != NULL); | |
| 490 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 491 | |
| 492 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 493 { | |
| 494 pFormFiller->OnDeSelected(pAnnot); | |
| 495 } | |
| 496 } | |
| 497 | |
| 498 void CFFL_IFormFiller::OnSelected(CPDFSDK_Annot* pAnnot) | |
| 499 { | |
| 500 ASSERT(pAnnot != NULL); | |
| 501 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 502 | |
| 503 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 504 { | |
| 505 pFormFiller->OnSelected(pAnnot); | |
| 506 } | |
| 507 } | |
| 508 | |
| 509 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 474 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) |
| 510 { | 475 { |
| 511 if(!pAnnot) return FALSE; | 476 if(!pAnnot) return FALSE; |
| 512 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 477 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 513 | 478 |
| 514 if (!m_bNotifying) | 479 if (!m_bNotifying) |
| 515 { | 480 { |
| 516 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 481 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 517 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) | 482 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) |
| 518 { | 483 { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) | 657 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) |
| 693 { | 658 { |
| 694 auto it = m_Maps.find(pAnnot); | 659 auto it = m_Maps.find(pAnnot); |
| 695 if (it == m_Maps.end()) | 660 if (it == m_Maps.end()) |
| 696 return; | 661 return; |
| 697 | 662 |
| 698 delete it->second; | 663 delete it->second; |
| 699 m_Maps.erase(it); | 664 m_Maps.erase(it); |
| 700 } | 665 } |
| 701 | 666 |
| 702 void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameFie
ld, FX_BOOL bNext) | |
| 703 { | |
| 704 | |
| 705 } | |
| 706 | |
| 707 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX
_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet) | 667 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX
_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet) |
| 708 { | 668 { |
| 709 ASSERT(pPrivateData != NULL); | 669 ASSERT(pPrivateData != NULL); |
| 710 | 670 |
| 711 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 671 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 712 | 672 |
| 713 | 673 |
| 714 | 674 |
| 715 | 675 |
| 716 CPDF_Rect rcPageView(0,0,0,0); | 676 CPDF_Rect rcPageView(0,0,0,0); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 fFactHeight = fBottom; | 748 fFactHeight = fBottom; |
| 789 bBottom = TRUE; | 749 bBottom = TRUE; |
| 790 } | 750 } |
| 791 } | 751 } |
| 792 } | 752 } |
| 793 | 753 |
| 794 nRet = bBottom ? 0 : 1; | 754 nRet = bBottom ? 0 : 1; |
| 795 fPopupRet = fFactHeight; | 755 fPopupRet = fFactHeight; |
| 796 } | 756 } |
| 797 | 757 |
| 798 void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcW
indow) | |
| 799 { | |
| 800 ASSERT(pPrivateData != NULL); | |
| 801 | |
| 802 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | |
| 803 | |
| 804 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, TRUE)) | |
| 805 { | |
| 806 | |
| 807 CPDF_Rect rcOld = pFormFiller->PWLtoFFL(pFormFiller->GetWindowRe
ct(pData->pPageView)); | |
| 808 CPDF_Rect rcNew = pFormFiller->PWLtoFFL(rcWindow); | |
| 809 pFormFiller->SetWindowRect(pData->pPageView, rcWindow); | |
| 810 | |
| 811 CPDF_Rect unRect = rcOld; | |
| 812 unRect.Union(rcNew); | |
| 813 //FX_RECT rcRect = unRect.GetOutterRect(); | |
| 814 unRect.left = (FX_FLOAT)(unRect.left - 0.5); | |
| 815 unRect.right = (FX_FLOAT)(unRect.right + 0.5); | |
| 816 unRect.top = (FX_FLOAT)(unRect.top + 0.5); | |
| 817 unRect.bottom = (FX_FLOAT)(unRect.bottom -0.5); | |
| 818 m_pApp->FFI_Invalidate(pData->pWidget->GetPDFPage(), unRect.left
, unRect.top, unRect.right, unRect.bottom); | |
| 819 } | |
| 820 } | |
| 821 | |
| 822 void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int3
2_t nKeyCode, CFX_WideString& strChange, | |
| 823 const CFX_Wid
eString& strChangeEx, FX_BOOL bKeyDown, | |
| 824 FX_BOOL & bRC
, FX_BOOL & bExit) | |
| 825 { | |
| 826 ASSERT(pPrivateData != NULL); | |
| 827 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | |
| 828 ASSERT(pData->pWidget != NULL); | |
| 829 | |
| 830 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | |
| 831 ASSERT(pFormFiller != NULL); | |
| 832 | |
| 833 pFormFiller->OnKeyStroke(bKeyDown); | |
| 834 } | |
| 835 | |
| 836 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageVi
ew* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) | 758 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageVi
ew* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) |
| 837 { | 759 { |
| 838 if (!m_bNotifying) | 760 if (!m_bNotifying) |
| 839 { | 761 { |
| 840 ASSERT(pWidget != NULL); | 762 ASSERT(pWidget != NULL); |
| 841 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) | 763 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) |
| 842 { | 764 { |
| 843 m_bNotifying = TRUE; | 765 m_bNotifying = TRUE; |
| 844 pWidget->ClearAppModified(); | 766 pWidget->ClearAppModified(); |
| 845 | 767 |
| 846 ASSERT(pPageView != NULL); | 768 ASSERT(pPageView != NULL); |
| 847 // CReader_DocView* pDocView = pPageView->GetDocView(); | |
| 848 // ASSERT(pDocView != NULL); | |
| 849 | |
| 850 | |
| 851 | 769 |
| 852 PDFSDK_FieldAction fa; | 770 PDFSDK_FieldAction fa; |
| 853 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 771 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 854 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 772 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 855 fa.bWillCommit = TRUE; | 773 fa.bWillCommit = TRUE; |
| 856 fa.bKeyDown = TRUE; | 774 fa.bKeyDown = TRUE; |
| 857 fa.bRC = TRUE; | 775 fa.bRC = TRUE; |
| 858 | 776 |
| 859 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FA
LSE); | 777 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FA
LSE); |
| 860 ASSERT(pFormFiller != NULL); | 778 ASSERT(pFormFiller != NULL); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 888 |
| 971 ASSERT(pPageView != NULL); | 889 ASSERT(pPageView != NULL); |
| 972 ASSERT(pAnnot != NULL); | 890 ASSERT(pAnnot != NULL); |
| 973 | 891 |
| 974 if(pPageView) | 892 if(pPageView) |
| 975 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); | 893 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); |
| 976 else | 894 else |
| 977 return FALSE; | 895 return FALSE; |
| 978 } | 896 } |
| 979 | 897 |
| 980 void CFFL_IFormFiller::BeforeUndo(CPDFSDK_Document* pDocument) | |
| 981 { | |
| 982 | |
| 983 } | |
| 984 | |
| 985 void CFFL_IFormFiller::BeforeRedo(CPDFSDK_Document* pDocument) | |
| 986 { | |
| 987 BeforeUndo(pDocument); | |
| 988 } | |
| 989 | |
| 990 void CFFL_IFormFiller::AfterUndo(CPDFSDK_Document* pDocument) | |
| 991 { | |
| 992 } | |
| 993 | |
| 994 void CFFL_IFormFiller::AfterRedo(CPDFSDK_Document* pDocument) | |
| 995 { | |
| 996 } | |
| 997 | |
| 998 FX_BOOL CFFL_IFormFiller::CanCopy(CPDFSDK_Document* pDocument) | |
| 999 { | |
| 1000 | |
| 1001 return FALSE; | |
| 1002 } | |
| 1003 | |
| 1004 FX_BOOL CFFL_IFormFiller::CanCut(CPDFSDK_Document* pDocument) | |
| 1005 { | |
| 1006 | |
| 1007 return FALSE; | |
| 1008 } | |
| 1009 | |
| 1010 FX_BOOL CFFL_IFormFiller::CanPaste(CPDFSDK_Document* pDocument) | |
| 1011 { | |
| 1012 | |
| 1013 return FALSE; | |
| 1014 } | |
| 1015 | |
| 1016 void CFFL_IFormFiller::DoCopy(CPDFSDK_Document* pDocument) | |
| 1017 { | |
| 1018 } | |
| 1019 | |
| 1020 void CFFL_IFormFiller::DoCut(CPDFSDK_Document* pDocument) | |
| 1021 { | |
| 1022 } | |
| 1023 | |
| 1024 void CFFL_IFormFiller::DoPaste(CPDFSDK_Document* pDocument) | |
| 1025 { | |
| 1026 | |
| 1027 } | |
| 1028 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData
, int32_t nKeyCode, | 898 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData
, int32_t nKeyCode, |
| 1029
CFX_WideString & strChange, const CFX_WideString& strChangeEx, | 899
CFX_WideString & strChange, const CFX_WideString& strChangeEx, |
| 1030
int nSelStart, int nSelEnd, | 900
int nSelStart, int nSelEnd, |
| 1031
FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) | 901
FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) |
| 1032 { | 902 { |
| 1033 ASSERT(pPrivateData != NULL); | 903 ASSERT(pPrivateData != NULL); |
| 1034 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 904 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 1035 ASSERT(pData->pWidget != NULL); | 905 ASSERT(pData->pWidget != NULL); |
| 1036 | 906 |
| 1037 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 907 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 ASSERT(pPrivateData != NULL); | 986 ASSERT(pPrivateData != NULL); |
| 1117 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 987 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 1118 ASSERT(pData->pWidget != NULL); | 988 ASSERT(pData->pWidget != NULL); |
| 1119 | 989 |
| 1120 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 990 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
| 1121 ASSERT(pFormFiller != NULL); | 991 ASSERT(pFormFiller != NULL); |
| 1122 | 992 |
| 1123 if (!bEditOrList) | 993 if (!bEditOrList) |
| 1124 pFormFiller->OnKeyStroke(bExit); | 994 pFormFiller->OnKeyStroke(bExit); |
| 1125 } | 995 } |
| OLD | NEW |