From 624b6c1e0fc6a5b0467061ef37b6db6856681afb Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 5 Mar 2015 16:30:09 -0800 Subject: Make conversion between CPDF_Action and its dictionary explicit. Precursor to taking a second shot at cleaning up the FPDF_* APIs. A FPDF_Action is a CPDF_Dictionary, and a CPDF_Action is a structure holding a FPDF_Action. This goes against the convention that FPDF_ types get cast to CPDF_* types, so we want to make it clear where objects are getting constructed, etc. Also tidy fpdf_actionhandler.cpp because it bugs me. R=thestig@chromium.org Review URL: https://codereview.chromium.org/984773002 --- fpdfsdk/src/fsdk_baseform.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'fpdfsdk/src/fsdk_baseform.cpp') diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index 6203f85662..a53e914b5c 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -1623,24 +1623,23 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) case CPDF_AAction::PageVisible: case CPDF_AAction::PageInvisible: return CPDFSDK_Annot::GetAAction(eAAT); + case CPDF_AAction::KeyStroke: case CPDF_AAction::Format: case CPDF_AAction::Validate: case CPDF_AAction::Calculate: { CPDF_FormField* pField = this->GetFormField(); - ASSERT(pField != NULL); - if (CPDF_AAction aa = pField->GetAdditionalAction()) return aa.GetAction(eAAT); - else - return CPDFSDK_Annot::GetAAction(eAAT); + + return CPDFSDK_Annot::GetAAction(eAAT); } default: - return NULL; + break; } - return NULL; + return CPDF_Action(); } @@ -2161,7 +2160,7 @@ void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { - ASSERT(action != NULL); + ASSERT(action); CPDF_ActionFields af = action.GetWidgets(); CFX_PtrArray fieldObjects; @@ -2217,13 +2216,13 @@ FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { - ASSERT(action != NULL); + ASSERT(action); ASSERT(m_pInterForm != NULL); CFX_WideString sDestination = action.GetFilePath(); if (sDestination.IsEmpty()) return FALSE; - CPDF_Dictionary* pActionDict = action; + CPDF_Dictionary* pActionDict = action.GetDict(); if (pActionDict->KeyExist("Fields")) { CPDF_ActionFields af = action.GetWidgets(); @@ -2448,29 +2447,22 @@ FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { - ASSERT(action != NULL); - - CPDF_Dictionary* pActionDict = action; + ASSERT(action); + CPDF_Dictionary* pActionDict = action.GetDict(); if (pActionDict->KeyExist("Fields")) { CPDF_ActionFields af = action.GetWidgets(); FX_DWORD dwFlags = action.GetFlags(); - + CFX_PtrArray fieldObjects; af.GetAllFields(fieldObjects); CFX_PtrArray fields; GetFieldFromObjects(fieldObjects, fields); - - ASSERT(m_pInterForm != NULL); - return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE); } - else - { - ASSERT(m_pInterForm != NULL); - return m_pInterForm->ResetForm(TRUE); - } + + return m_pInterForm->ResetForm(TRUE); } FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) -- cgit v1.2.3