summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-03 14:40:14 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-03 14:40:14 -0800
commite8ea737bf9ef95b406c74fc3b1120f3fa6c4e227 (patch)
tree8d7ca9a4a00a47d1be6438cc7967ec760c978329 /fpdfsdk
parent7c87508ae4b8300caf97aebffae42ba2c7fd6e52 (diff)
downloadpdfium-e8ea737bf9ef95b406c74fc3b1120f3fa6c4e227.tar.xz
Fix prototypes for CPDF_FormNotify.
Avoid some const casts, unused return types, etc. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1660633003 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fsdk_baseform.h31
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp152
2 files changed, 83 insertions, 100 deletions
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index f81f576cd0..cd4b311e2e 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -197,12 +197,9 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
void EnableCalculate(FX_BOOL bEnabled);
FX_BOOL IsCalculateEnabled() const;
- void OnKeyStrokeCommit(CPDF_FormField* pFormField,
- CFX_WideString& csValue,
- FX_BOOL& bRC);
- void OnValidate(CPDF_FormField* pFormField,
- CFX_WideString& csValue,
- FX_BOOL& bRC);
+ FX_BOOL OnKeyStrokeCommit(CPDF_FormField* pFormField,
+ const CFX_WideString& csValue);
+ FX_BOOL OnValidate(CPDF_FormField* pFormField, const CFX_WideString& csValue);
void OnCalculate(CPDF_FormField* pFormField = NULL);
CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated);
@@ -231,18 +228,18 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt);
private:
- // CPDF_FormNotify
- int BeforeValueChange(const CPDF_FormField* pField,
- CFX_WideString& csValue) override;
- int AfterValueChange(const CPDF_FormField* pField) override;
- int BeforeSelectionChange(const CPDF_FormField* pField,
- CFX_WideString& csValue) override;
- int AfterSelectionChange(const CPDF_FormField* pField) override;
+ // CPDF_FormNotify:
+ int BeforeValueChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) override;
+ void AfterValueChange(CPDF_FormField* pField) override;
+ int BeforeSelectionChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) override;
+ void AfterSelectionChange(CPDF_FormField* pField) override;
void AfterCheckedStatusChange(CPDF_FormField* pField) override;
- int BeforeFormReset(const CPDF_InterForm* pForm) override;
- int AfterFormReset(const CPDF_InterForm* pForm) override;
- int BeforeFormImportData(const CPDF_InterForm* pForm) override;
- int AfterFormImportData(const CPDF_InterForm* pForm) override;
+ int BeforeFormReset(CPDF_InterForm* pForm) override;
+ void AfterFormReset(CPDF_InterForm* pForm) override;
+ int BeforeFormImportData(CPDF_InterForm* pForm) override;
+ void AfterFormImportData(CPDF_InterForm* pForm) override;
FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile,
CFX_WideString csTxtFile);
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index f2eb3978f3..86c41dc048 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -1684,46 +1684,46 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) {
}
}
-void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
- CFX_WideString& csValue,
- FX_BOOL& bRC) {
+FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
+ const CFX_WideString& csValue) {
CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
- if (action) {
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
- PDFSDK_FieldAction fa;
- fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
- fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
- fa.sValue = csValue;
-
- pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
- m_pDocument, pFormField, fa);
- bRC = fa.bRC;
- }
- }
-}
+ if (!aAction || !aAction.ActionExist(CPDF_AAction::KeyStroke))
+ return TRUE;
+
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
+ if (!action)
+ return TRUE;
-void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
- CFX_WideString& csValue,
- FX_BOOL& bRC) {
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
+ PDFSDK_FieldAction fa;
+ fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
+ fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
+ fa.sValue = csValue;
+ pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
+ m_pDocument, pFormField, fa);
+ return fa.bRC;
+}
+
+FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
+ const CFX_WideString& csValue) {
CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
- if (action) {
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
- PDFSDK_FieldAction fa;
- fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
- fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
- fa.sValue = csValue;
-
- pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate,
- m_pDocument, pFormField, fa);
- bRC = fa.bRC;
- }
- }
+ if (!aAction || !aAction.ActionExist(CPDF_AAction::Validate))
+ return TRUE;
+
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
+ if (!action)
+ return TRUE;
+
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
+ PDFSDK_FieldAction fa;
+ fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
+ fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
+ fa.sValue = csValue;
+ pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate,
+ m_pDocument, pFormField, fa);
+ return fa.bRC;
}
FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
@@ -1949,64 +1949,52 @@ std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects(
return fields;
}
-int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField,
- CFX_WideString& csValue) {
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
- if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
- FX_BOOL bRC = TRUE;
- OnKeyStrokeCommit(pFormField, csValue, bRC);
- if (bRC) {
- OnValidate(pFormField, csValue, bRC);
- return bRC ? 1 : -1;
- }
+int CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) {
+ int nType = pField->GetFieldType();
+ if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD)
+ return 0;
+
+ if (!OnKeyStrokeCommit(pField, csValue))
return -1;
- }
- return 0;
+
+ if (!OnValidate(pField, csValue))
+ return -1;
+
+ return 1;
}
-int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) {
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
+void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) {
+ int nType = pField->GetFieldType();
if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
- OnCalculate(pFormField);
+ OnCalculate(pField);
FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = OnFormat(pFormField, bFormated);
- if (bFormated)
- ResetFieldAppearance(pFormField, sValue.c_str(), TRUE);
- else
- ResetFieldAppearance(pFormField, NULL, TRUE);
- UpdateField(pFormField);
+ CFX_WideString sValue = OnFormat(pField, bFormated);
+ ResetFieldAppearance(pField, bFormated ? sValue.c_str() : nullptr, TRUE);
+ UpdateField(pField);
}
- return 0;
}
-int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField,
- CFX_WideString& csValue) {
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) {
+ if (pField->GetFieldType() != FIELDTYPE_LISTBOX)
return 0;
- FX_BOOL bRC = TRUE;
- OnKeyStrokeCommit(pFormField, csValue, bRC);
- if (!bRC)
+ if (!OnKeyStrokeCommit(pField, csValue))
return -1;
- OnValidate(pFormField, csValue, bRC);
- if (!bRC)
+ if (!OnValidate(pField, csValue))
return -1;
return 1;
}
-int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) {
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX) {
- OnCalculate(pFormField);
- ResetFieldAppearance(pFormField, NULL, TRUE);
- UpdateField(pFormField);
+void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) {
+ if (pField->GetFieldType() == FIELDTYPE_LISTBOX) {
+ OnCalculate(pField);
+ ResetFieldAppearance(pField, NULL, TRUE);
+ UpdateField(pField);
}
- return 0;
}
void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) {
@@ -2017,22 +2005,20 @@ void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) {
}
}
-int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm) {
+int CPDFSDK_InterForm::BeforeFormReset(CPDF_InterForm* pForm) {
return 0;
}
-int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm) {
+void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) {
OnCalculate(nullptr);
- return 0;
}
-int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm) {
+int CPDFSDK_InterForm::BeforeFormImportData(CPDF_InterForm* pForm) {
return 0;
}
-int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) {
+void CPDFSDK_InterForm::AfterFormImportData(CPDF_InterForm* pForm) {
OnCalculate(nullptr);
- return 0;
}
FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) {