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 "fpdfsdk/formfiller/cffl_interactiveformfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" |
8 | 8 |
9 #include "core/fpdfapi/page/cpdf_page.h" | 9 #include "core/fpdfapi/page/cpdf_page.h" |
10 #include "core/fpdfapi/parser/cpdf_document.h" | 10 #include "core/fpdfapi/parser/cpdf_document.h" |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 684 } |
685 } | 685 } |
686 } | 686 } |
687 | 687 |
688 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, | 688 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, |
689 CPDFSDK_PageView* pPageView, | 689 CPDFSDK_PageView* pPageView, |
690 FX_BOOL& bExit, | 690 FX_BOOL& bExit, |
691 uint32_t nFlag) { | 691 uint32_t nFlag) { |
692 if (!m_bNotifying) { | 692 if (!m_bNotifying) { |
693 ASSERT(pWidget); | 693 ASSERT(pWidget); |
694 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 694 CPDFSDK_InterForm* pInterForm = |
695 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 695 pPageView->GetFormFillEnv()->GetSDKDocument()->GetInterForm(); |
696 pInterForm->OnCalculate(pWidget->GetFormField()); | 696 pInterForm->OnCalculate(pWidget->GetFormField()); |
697 m_bNotifying = FALSE; | 697 m_bNotifying = FALSE; |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, | 701 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, |
702 CPDFSDK_PageView* pPageView, | 702 CPDFSDK_PageView* pPageView, |
703 FX_BOOL& bExit, | 703 FX_BOOL& bExit, |
704 uint32_t nFlag) { | 704 uint32_t nFlag) { |
705 if (!m_bNotifying) { | 705 if (!m_bNotifying) { |
706 ASSERT(pWidget); | 706 ASSERT(pWidget); |
707 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 707 CPDFSDK_InterForm* pInterForm = |
708 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 708 pPageView->GetFormFillEnv()->GetSDKDocument()->GetInterForm(); |
709 | 709 |
710 FX_BOOL bFormatted = FALSE; | 710 FX_BOOL bFormatted = FALSE; |
711 CFX_WideString sValue = | 711 CFX_WideString sValue = |
712 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); | 712 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); |
713 | 713 |
714 if (bExit) | 714 if (bExit) |
715 return; | 715 return; |
716 | 716 |
717 if (bFormatted) { | 717 if (bFormatted) { |
718 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, TRUE); | 718 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, TRUE); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 } | 925 } |
926 } | 926 } |
927 #endif // PDF_ENABLE_XFA | 927 #endif // PDF_ENABLE_XFA |
928 | 928 |
929 if (!m_bNotifying) { | 929 if (!m_bNotifying) { |
930 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { | 930 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { |
931 m_bNotifying = TRUE; | 931 m_bNotifying = TRUE; |
932 int nAge = pData->pWidget->GetAppearanceAge(); | 932 int nAge = pData->pWidget->GetAppearanceAge(); |
933 int nValueAge = pData->pWidget->GetValueAge(); | 933 int nValueAge = pData->pWidget->GetValueAge(); |
934 | 934 |
935 CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument(); | 935 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
| 936 pData->pPageView->GetFormFillEnv(); |
936 | 937 |
937 PDFSDK_FieldAction fa; | 938 PDFSDK_FieldAction fa; |
938 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 939 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); |
939 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 940 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); |
940 fa.sChange = strChange; | 941 fa.sChange = strChange; |
941 fa.sChangeEx = strChangeEx; | 942 fa.sChangeEx = strChangeEx; |
942 fa.bKeyDown = bKeyDown; | 943 fa.bKeyDown = bKeyDown; |
943 fa.bWillCommit = FALSE; | 944 fa.bWillCommit = FALSE; |
944 fa.bRC = TRUE; | 945 fa.bRC = TRUE; |
945 fa.nSelStart = nSelStart; | 946 fa.nSelStart = nSelStart; |
(...skipping 20 matching lines...) Expand all Loading... |
966 | 967 |
967 if (fa.bRC) { | 968 if (fa.bRC) { |
968 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, | 969 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, |
969 fa); | 970 fa); |
970 bRC = FALSE; | 971 bRC = FALSE; |
971 } else { | 972 } else { |
972 pFormFiller->RestoreState(pData->pPageView); | 973 pFormFiller->RestoreState(pData->pPageView); |
973 bRC = FALSE; | 974 bRC = FALSE; |
974 } | 975 } |
975 | 976 |
976 if (pDocument->GetFocusAnnot() != pData->pWidget) { | 977 if (pFormFillEnv->GetSDKDocument()->GetFocusAnnot() != pData->pWidget) { |
977 pFormFiller->CommitData(pData->pPageView, nFlag); | 978 pFormFiller->CommitData(pData->pPageView, nFlag); |
978 bExit = TRUE; | 979 bExit = TRUE; |
979 } | 980 } |
980 } else { | 981 } else { |
981 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { | 982 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { |
982 bExit = TRUE; | 983 bExit = TRUE; |
983 m_bNotifying = FALSE; | 984 m_bNotifying = FALSE; |
984 return; | 985 return; |
985 } | 986 } |
986 } | 987 } |
987 | 988 |
988 m_bNotifying = FALSE; | 989 m_bNotifying = FALSE; |
989 } | 990 } |
990 } | 991 } |
991 } | 992 } |
OLD | NEW |