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

Side by Side Diff: fpdfsdk/src/fsdk_baseform.cpp

Issue 1660633003: Fix prototypes for CPDF_FormNotify. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/include/fsdk_baseform.h" 7 #include "fpdfsdk/include/fsdk_baseform.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); 1677 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
1678 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); 1678 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE);
1679 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); 1679 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget);
1680 1680
1681 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, 1681 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right,
1682 rcBBox.bottom); 1682 rcBBox.bottom);
1683 } 1683 }
1684 } 1684 }
1685 } 1685 }
1686 1686
1687 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, 1687 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
1688 CFX_WideString& csValue, 1688 const CFX_WideString& csValue) {
1689 FX_BOOL& bRC) {
1690 CPDF_AAction aAction = pFormField->GetAdditionalAction(); 1689 CPDF_AAction aAction = pFormField->GetAdditionalAction();
1691 if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) { 1690 if (!aAction || !aAction.ActionExist(CPDF_AAction::KeyStroke))
1692 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); 1691 return TRUE;
1693 if (action) {
1694 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
1695 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
1696 PDFSDK_FieldAction fa;
1697 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
1698 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
1699 fa.sValue = csValue;
1700 1692
1701 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, 1693 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
1702 m_pDocument, pFormField, fa); 1694 if (!action)
1703 bRC = fa.bRC; 1695 return TRUE;
1704 } 1696
1705 } 1697 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
1698 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
1699 PDFSDK_FieldAction fa;
1700 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
1701 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
1702 fa.sValue = csValue;
1703 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
1704 m_pDocument, pFormField, fa);
1705 return fa.bRC;
1706 } 1706 }
1707 1707
1708 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, 1708 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
1709 CFX_WideString& csValue, 1709 const CFX_WideString& csValue) {
1710 FX_BOOL& bRC) {
1711 CPDF_AAction aAction = pFormField->GetAdditionalAction(); 1710 CPDF_AAction aAction = pFormField->GetAdditionalAction();
1712 if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) { 1711 if (!aAction || !aAction.ActionExist(CPDF_AAction::Validate))
1713 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); 1712 return TRUE;
1714 if (action) {
1715 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
1716 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
1717 PDFSDK_FieldAction fa;
1718 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
1719 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
1720 fa.sValue = csValue;
1721 1713
1722 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, 1714 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
1723 m_pDocument, pFormField, fa); 1715 if (!action)
1724 bRC = fa.bRC; 1716 return TRUE;
1725 } 1717
1726 } 1718 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
1719 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
1720 PDFSDK_FieldAction fa;
1721 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
1722 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
1723 fa.sValue = csValue;
1724 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate,
1725 m_pDocument, pFormField, fa);
1726 return fa.bRC;
1727 } 1727 }
1728 1728
1729 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { 1729 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
1730 ASSERT(action); 1730 ASSERT(action);
1731 1731
1732 CPDF_ActionFields af = action.GetWidgets(); 1732 CPDF_ActionFields af = action.GetWidgets();
1733 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); 1733 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
1734 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); 1734 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
1735 1735
1736 FX_BOOL bHide = action.GetHideStatus(); 1736 FX_BOOL bHide = action.GetHideStatus();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 if (pObject && pObject->IsString()) { 1942 if (pObject && pObject->IsString()) {
1943 CFX_WideString csName = pObject->GetUnicodeText(); 1943 CFX_WideString csName = pObject->GetUnicodeText();
1944 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); 1944 CPDF_FormField* pField = m_pInterForm->GetField(0, csName);
1945 if (pField) 1945 if (pField)
1946 fields.push_back(pField); 1946 fields.push_back(pField);
1947 } 1947 }
1948 } 1948 }
1949 return fields; 1949 return fields;
1950 } 1950 }
1951 1951
1952 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, 1952 int CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField,
1953 CFX_WideString& csValue) { 1953 const CFX_WideString& csValue) {
1954 CPDF_FormField* pFormField = (CPDF_FormField*)pField; 1954 int nType = pField->GetFieldType();
1955 int nType = pFormField->GetFieldType(); 1955 if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD)
1956 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
1957 FX_BOOL bRC = TRUE;
1958 OnKeyStrokeCommit(pFormField, csValue, bRC);
1959 if (bRC) {
1960 OnValidate(pFormField, csValue, bRC);
1961 return bRC ? 1 : -1;
1962 }
1963 return -1;
1964 }
1965 return 0;
1966 }
1967
1968 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) {
1969 CPDF_FormField* pFormField = (CPDF_FormField*)pField;
1970 int nType = pFormField->GetFieldType();
1971 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
1972 OnCalculate(pFormField);
1973 FX_BOOL bFormated = FALSE;
1974 CFX_WideString sValue = OnFormat(pFormField, bFormated);
1975 if (bFormated)
1976 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE);
1977 else
1978 ResetFieldAppearance(pFormField, NULL, TRUE);
1979 UpdateField(pFormField);
1980 }
1981 return 0;
1982 }
1983
1984 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField,
1985 CFX_WideString& csValue) {
1986 CPDF_FormField* pFormField = (CPDF_FormField*)pField;
1987 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
1988 return 0; 1956 return 0;
1989 1957
1990 FX_BOOL bRC = TRUE; 1958 if (!OnKeyStrokeCommit(pField, csValue))
1991 OnKeyStrokeCommit(pFormField, csValue, bRC);
1992 if (!bRC)
1993 return -1; 1959 return -1;
1994 1960
1995 OnValidate(pFormField, csValue, bRC); 1961 if (!OnValidate(pField, csValue))
1996 if (!bRC)
1997 return -1; 1962 return -1;
1998 1963
1999 return 1; 1964 return 1;
2000 } 1965 }
2001 1966
2002 int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) { 1967 void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) {
2003 CPDF_FormField* pFormField = (CPDF_FormField*)pField; 1968 int nType = pField->GetFieldType();
2004 if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX) { 1969 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
2005 OnCalculate(pFormField); 1970 OnCalculate(pField);
2006 ResetFieldAppearance(pFormField, NULL, TRUE); 1971 FX_BOOL bFormated = FALSE;
2007 UpdateField(pFormField); 1972 CFX_WideString sValue = OnFormat(pField, bFormated);
1973 ResetFieldAppearance(pField, bFormated ? sValue.c_str() : nullptr, TRUE);
1974 UpdateField(pField);
2008 } 1975 }
2009 return 0; 1976 }
1977
1978 int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField,
1979 const CFX_WideString& csValue) {
1980 if (pField->GetFieldType() != FIELDTYPE_LISTBOX)
1981 return 0;
1982
1983 if (!OnKeyStrokeCommit(pField, csValue))
1984 return -1;
1985
1986 if (!OnValidate(pField, csValue))
1987 return -1;
1988
1989 return 1;
1990 }
1991
1992 void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) {
1993 if (pField->GetFieldType() == FIELDTYPE_LISTBOX) {
1994 OnCalculate(pField);
1995 ResetFieldAppearance(pField, NULL, TRUE);
1996 UpdateField(pField);
1997 }
2010 } 1998 }
2011 1999
2012 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { 2000 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) {
2013 int nType = pField->GetFieldType(); 2001 int nType = pField->GetFieldType();
2014 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) { 2002 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) {
2015 OnCalculate(pField); 2003 OnCalculate(pField);
2016 UpdateField(pField); 2004 UpdateField(pField);
2017 } 2005 }
2018 } 2006 }
2019 2007
2020 int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm) { 2008 int CPDFSDK_InterForm::BeforeFormReset(CPDF_InterForm* pForm) {
2021 return 0; 2009 return 0;
2022 } 2010 }
2023 2011
2024 int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm) { 2012 void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) {
2025 OnCalculate(nullptr); 2013 OnCalculate(nullptr);
2014 }
2015
2016 int CPDFSDK_InterForm::BeforeFormImportData(CPDF_InterForm* pForm) {
2026 return 0; 2017 return 0;
2027 } 2018 }
2028 2019
2029 int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm) { 2020 void CPDFSDK_InterForm::AfterFormImportData(CPDF_InterForm* pForm) {
2030 return 0;
2031 }
2032
2033 int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) {
2034 OnCalculate(nullptr); 2021 OnCalculate(nullptr);
2035 return 0;
2036 } 2022 }
2037 2023
2038 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { 2024 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) {
2039 if (nFieldType < 1 || nFieldType > kNumFieldTypes) 2025 if (nFieldType < 1 || nFieldType > kNumFieldTypes)
2040 return FALSE; 2026 return FALSE;
2041 return m_bNeedHightlight[nFieldType - 1]; 2027 return m_bNeedHightlight[nFieldType - 1];
2042 } 2028 }
2043 2029
2044 void CPDFSDK_InterForm::RemoveAllHighLight() { 2030 void CPDFSDK_InterForm::RemoveAllHighLight() {
2045 for (int i = 0; i < kNumFieldTypes; ++i) 2031 for (int i = 0; i < kNumFieldTypes; ++i)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 break; 2213 break;
2228 } 2214 }
2229 } 2215 }
2230 } 2216 }
2231 2217
2232 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { 2218 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) {
2233 CPDF_Rect rcAnnot; 2219 CPDF_Rect rcAnnot;
2234 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); 2220 pAnnot->GetPDFAnnot()->GetRect(rcAnnot);
2235 return rcAnnot; 2221 return rcAnnot;
2236 } 2222 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698