diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-11 16:56:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-11 16:56:00 +0000 |
commit | 073ecf4192469ee4485c826dcee0cb8ece1b94a2 (patch) | |
tree | aa6687acc434a24977b547144aa896168eaccc7b /fpdfsdk | |
parent | c345065e7aff3368198624f303e711a244e2f7ec (diff) | |
download | pdfium-073ecf4192469ee4485c826dcee0cb8ece1b94a2.tar.xz |
Rename InterForm classes to InteractiveForm.
Shorten some names to try to avoid
CPDF_InteractiveForm* pInteractiveForm = GetInteractiveForm();
Change-Id: I77fafd6c4cce20aa46908830afde12f87784680e
Reviewed-on: https://pdfium-review.googlesource.com/c/43815
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_actionhandler.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.h | 6 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interactiveform.cpp | 157 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interactiveform.h | 16 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 34 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.h | 10 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widgethandler.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_xfawidget.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_xfawidget.h | 10 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_xfawidgethandler.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 14 | ||||
-rw-r--r-- | fpdfsdk/fpdf_annot.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdf_formfill.cpp | 33 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_appstream.cpp | 8 |
18 files changed, 205 insertions, 185 deletions
diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp index 8093972e18..6d7fb9f2f9 100644 --- a/fpdfsdk/cpdfsdk_actionhandler.cpp +++ b/fpdfsdk/cpdfsdk_actionhandler.cpp @@ -212,9 +212,9 @@ bool CPDFSDK_ActionHandler::IsValidField( CPDF_Dictionary* pFieldDict) { ASSERT(pFieldDict); - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); - CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); - return !!pPDFInterForm->GetFieldByDict(pFieldDict); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pPDFForm = pForm->GetInteractiveForm(); + return !!pPDFForm->GetFieldByDict(pFieldDict); } bool CPDFSDK_ActionHandler::ExecuteFieldAction( @@ -509,8 +509,8 @@ void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( bool CPDFSDK_ActionHandler::DoAction_Hide( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); - if (pInterForm->DoAction_Hide(action)) { + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); + if (pForm->DoAction_Hide(action)) { pFormFillEnv->SetChangeMark(); return true; } @@ -520,15 +520,15 @@ bool CPDFSDK_ActionHandler::DoAction_Hide( bool CPDFSDK_ActionHandler::DoAction_SubmitForm( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); - return pInterForm->DoAction_SubmitForm(action); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); + return pForm->DoAction_SubmitForm(action); } void CPDFSDK_ActionHandler::DoAction_ResetForm( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); - pInterForm->DoAction_ResetForm(action); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); + pForm->DoAction_ResetForm(action); } void CPDFSDK_ActionHandler::RunScriptForAction( diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 8f490ca2bc..568d89e96a 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -45,8 +45,8 @@ CPDFSDK_FormFillEnvironment::~CPDFSDK_FormFillEnvironment() { m_bBeingDestroyed = true; ClearAllFocusedAnnots(); - // |m_PageMap| will try to access |m_pInterForm| when it cleans itself up. - // Make sure it is deleted before |m_pInterForm|. + // |m_PageMap| will try to access |m_pInteractiveForm| when it cleans itself + // up. Make sure it is deleted before |m_pInteractiveForm|. m_PageMap.clear(); // |m_pAnnotHandlerMgr| will try to access |m_pFormFiller| when it cleans @@ -623,10 +623,10 @@ IPDF_Page* CPDFSDK_FormFillEnvironment::GetPage(int nIndex) { m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc.Get()), nIndex)); } -CPDFSDK_InterForm* CPDFSDK_FormFillEnvironment::GetInterForm() { - if (!m_pInterForm) - m_pInterForm = pdfium::MakeUnique<CPDFSDK_InterForm>(this); - return m_pInterForm.get(); +CPDFSDK_InteractiveForm* CPDFSDK_FormFillEnvironment::GetInteractiveForm() { + if (!m_pInteractiveForm) + m_pInteractiveForm = pdfium::MakeUnique<CPDFSDK_InteractiveForm>(this); + return m_pInteractiveForm.get(); } void CPDFSDK_FormFillEnvironment::UpdateAllViews(CPDFSDK_PageView* pSender, diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h index 46986c8ae0..a7fb94a922 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.h +++ b/fpdfsdk/cpdfsdk_formfillenvironment.h @@ -25,7 +25,7 @@ class CFFL_InteractiveFormFiller; class CFX_SystemHandler; class CPDFSDK_ActionHandler; class CPDFSDK_AnnotHandlerMgr; -class CPDFSDK_InterForm; +class CPDFSDK_InteractiveForm; class CPDFSDK_PageView; class IJS_Runtime; @@ -206,7 +206,7 @@ class CPDFSDK_FormFillEnvironment final CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. IJS_Runtime* GetIJSRuntime(); // Creates if not present. CPDFSDK_ActionHandler* GetActionHandler(); // Creates if not present. - CPDFSDK_InterForm* GetInterForm(); // Creates if not present. + CPDFSDK_InteractiveForm* GetInteractiveForm(); // Creates if not present. private: IPDF_Page* GetPage(int nIndex); @@ -216,7 +216,7 @@ class CPDFSDK_FormFillEnvironment final std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; std::unique_ptr<IJS_Runtime> m_pIJSRuntime; std::map<IPDF_Page*, std::unique_ptr<CPDFSDK_PageView>> m_PageMap; - std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; + std::unique_ptr<CPDFSDK_InteractiveForm> m_pInteractiveForm; CPDFSDK_Annot::ObservedPtr m_pFocusAnnot; UnownedPtr<CPDF_Document> const m_pCPDFDoc; std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller; diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 6a0cf85482..cc16cf431c 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -239,7 +239,7 @@ void ReportUnsupportedFeatures(CPDF_Document* pDoc) { } // XFA Forms - if (!pDoc->GetExtension() && CPDF_InterForm(pDoc).HasXFAForm()) + if (!pDoc->GetExtension() && CPDF_InteractiveForm(pDoc).HasXFAForm()) RaiseUnSupportError(FPDF_UNSP_DOC_XFAFORM); } diff --git a/fpdfsdk/cpdfsdk_interactiveform.cpp b/fpdfsdk/cpdfsdk_interactiveform.cpp index 843d1e99e0..b224b0ec88 100644 --- a/fpdfsdk/cpdfsdk_interactiveform.cpp +++ b/fpdfsdk/cpdfsdk_interactiveform.cpp @@ -120,24 +120,25 @@ bool FDFToURLEncodedData(std::vector<uint8_t>* pBuffer) { } // namespace -CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) +CPDFSDK_InteractiveForm::CPDFSDK_InteractiveForm( + CPDFSDK_FormFillEnvironment* pFormFillEnv) : m_pFormFillEnv(pFormFillEnv), - m_pInterForm(pdfium::MakeUnique<CPDF_InterForm>( + m_pInteractiveForm(pdfium::MakeUnique<CPDF_InteractiveForm>( m_pFormFillEnv->GetPDFDocument())) { ASSERT(m_pFormFillEnv); - m_pInterForm->SetFormNotify(this); + m_pInteractiveForm->SetFormNotify(this); RemoveAllHighLights(); } -CPDFSDK_InterForm::~CPDFSDK_InterForm() { +CPDFSDK_InteractiveForm::~CPDFSDK_InteractiveForm() { m_Map.clear(); #ifdef PDF_ENABLE_XFA m_XFAMap.clear(); #endif // PDF_ENABLE_XFA } -CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, - bool bNext) const { +CPDFSDK_Widget* CPDFSDK_InteractiveForm::GetSibling(CPDFSDK_Widget* pWidget, + bool bNext) const { auto pIterator = pdfium::MakeUnique<CPDFSDK_AnnotIterator>( pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET); @@ -145,7 +146,8 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, : pIterator->GetPrevAnnot(pWidget)); } -CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { +CPDFSDK_Widget* CPDFSDK_InteractiveForm::GetWidget( + CPDF_FormControl* pControl) const { if (!pControl) return nullptr; @@ -175,17 +177,18 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { return pPage ? ToCPDFSDKWidget(pPage->GetAnnotByDict(pControlDict)) : nullptr; } -void CPDFSDK_InterForm::GetWidgets( +void CPDFSDK_InteractiveForm::GetWidgets( const WideString& sFieldName, std::vector<CPDFSDK_Annot::ObservedPtr>* widgets) const { - for (int i = 0, sz = m_pInterForm->CountFields(sFieldName); i < sz; ++i) { - CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName); + for (int i = 0, sz = m_pInteractiveForm->CountFields(sFieldName); i < sz; + ++i) { + CPDF_FormField* pFormField = m_pInteractiveForm->GetField(i, sFieldName); ASSERT(pFormField); GetWidgets(pFormField, widgets); } } -void CPDFSDK_InterForm::GetWidgets( +void CPDFSDK_InteractiveForm::GetWidgets( CPDF_FormField* pField, std::vector<CPDFSDK_Annot::ObservedPtr>* widgets) const { for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { @@ -197,7 +200,7 @@ void CPDFSDK_InterForm::GetWidgets( } } -int CPDFSDK_InterForm::GetPageIndexByAnnotDict( +int CPDFSDK_InteractiveForm::GetPageIndexByAnnotDict( CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const { ASSERT(pAnnotDict); @@ -217,56 +220,57 @@ int CPDFSDK_InterForm::GetPageIndexByAnnotDict( return -1; } -void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, - CPDFSDK_Widget* pWidget) { +void CPDFSDK_InteractiveForm::AddMap(CPDF_FormControl* pControl, + CPDFSDK_Widget* pWidget) { m_Map[pControl] = pWidget; } -void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { +void CPDFSDK_InteractiveForm::RemoveMap(CPDF_FormControl* pControl) { m_Map.erase(pControl); } -void CPDFSDK_InterForm::EnableCalculate(bool bEnabled) { +void CPDFSDK_InteractiveForm::EnableCalculate(bool bEnabled) { m_bCalculate = bEnabled; } -bool CPDFSDK_InterForm::IsCalculateEnabled() const { +bool CPDFSDK_InteractiveForm::IsCalculateEnabled() const { return m_bCalculate; } #ifdef PDF_ENABLE_XFA -void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, - CPDFSDK_XFAWidget* pWidget) { +void CPDFSDK_InteractiveForm::AddXFAMap(CXFA_FFWidget* hWidget, + CPDFSDK_XFAWidget* pWidget) { ASSERT(hWidget); m_XFAMap[hWidget] = pWidget; } -void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { +void CPDFSDK_InteractiveForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { ASSERT(hWidget); m_XFAMap.erase(hWidget); } -CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { +CPDFSDK_XFAWidget* CPDFSDK_InteractiveForm::GetXFAWidget( + CXFA_FFWidget* hWidget) { ASSERT(hWidget); auto it = m_XFAMap.find(hWidget); return it != m_XFAMap.end() ? it->second : nullptr; } -void CPDFSDK_InterForm::XfaEnableCalculate(bool bEnabled) { +void CPDFSDK_InteractiveForm::XfaEnableCalculate(bool bEnabled) { m_bXfaCalculate = bEnabled; } -bool CPDFSDK_InterForm::IsXfaCalculateEnabled() const { +bool CPDFSDK_InteractiveForm::IsXfaCalculateEnabled() const { return m_bXfaCalculate; } -bool CPDFSDK_InterForm::IsXfaValidationsEnabled() { +bool CPDFSDK_InteractiveForm::IsXfaValidationsEnabled() { return m_bXfaValidationsEnabled; } -void CPDFSDK_InterForm::XfaSetValidationsEnabled(bool bEnabled) { +void CPDFSDK_InteractiveForm::XfaSetValidationsEnabled(bool bEnabled) { m_bXfaValidationsEnabled = bEnabled; } -void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField) { +void CPDFSDK_InteractiveForm::SynchronizeField(CPDF_FormField* pFormField) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) @@ -275,7 +279,7 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField) { } #endif // PDF_ENABLE_XFA -void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { +void CPDFSDK_InteractiveForm::OnCalculate(CPDF_FormField* pFormField) { if (!m_pFormFillEnv->IsJSPlatformPresent()) return; @@ -289,9 +293,9 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { return; IJS_Runtime* pRuntime = m_pFormFillEnv->GetIJSRuntime(); - int nSize = m_pInterForm->CountFieldsInCalculationOrder(); + int nSize = m_pInteractiveForm->CountFieldsInCalculationOrder(); for (int i = 0; i < nSize; i++) { - CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); + CPDF_FormField* pField = m_pInteractiveForm->GetFieldInCalculationOrder(i); if (!pField) continue; @@ -323,7 +327,8 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { } } -Optional<WideString> CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField) { +Optional<WideString> CPDFSDK_InteractiveForm::OnFormat( + CPDF_FormField* pFormField) { if (!m_pFormFillEnv->IsJSPlatformPresent()) return {}; @@ -353,9 +358,9 @@ Optional<WideString> CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField) { return {}; } -void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, - Optional<WideString> sValue, - bool bValueChanged) { +void CPDFSDK_InteractiveForm::ResetFieldAppearance(CPDF_FormField* pFormField, + Optional<WideString> sValue, + bool bValueChanged) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); ASSERT(pFormCtrl); @@ -364,7 +369,7 @@ void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, } } -void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { +void CPDFSDK_InteractiveForm::UpdateField(CPDF_FormField* pFormField) { auto* formfiller = m_pFormFillEnv->GetInteractiveFormFiller(); for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); @@ -381,8 +386,8 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { } } -bool CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, - const WideString& csValue) { +bool CPDFSDK_InteractiveForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, + const WideString& csValue) { CPDF_AAction aAction = pFormField->GetAdditionalAction(); if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) return true; @@ -400,8 +405,8 @@ bool CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, return fa.bRC; } -bool CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, - const WideString& csValue) { +bool CPDFSDK_InteractiveForm::OnValidate(CPDF_FormField* pFormField, + const WideString& csValue) { CPDF_AAction aAction = pFormField->GetAdditionalAction(); if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) return true; @@ -419,7 +424,7 @@ bool CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, return fa.bRC; } -bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { +bool CPDFSDK_InteractiveForm::DoAction_Hide(const CPDF_Action& action) { ASSERT(action.GetDict()); CPDF_ActionFields af(&action); @@ -452,7 +457,7 @@ bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { return bChanged; } -bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { +bool CPDFSDK_InteractiveForm::DoAction_SubmitForm(const CPDF_Action& action) { WideString sDestination = action.GetFilePath(); if (sDestination.IsEmpty()) return false; @@ -465,22 +470,23 @@ bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); if (!fields.empty()) { bool bIncludeOrExclude = !(dwFlags & 0x01); - if (!m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) + if (!m_pInteractiveForm->CheckRequiredFields(&fields, bIncludeOrExclude)) return false; return SubmitFields(sDestination, fields, bIncludeOrExclude, false); } } - if (!m_pInterForm->CheckRequiredFields(nullptr, true)) + if (!m_pInteractiveForm->CheckRequiredFields(nullptr, true)) return false; return SubmitForm(sDestination, false); } -bool CPDFSDK_InterForm::SubmitFields(const WideString& csDestination, - const std::vector<CPDF_FormField*>& fields, - bool bIncludeOrExclude, - bool bUrlEncoded) { +bool CPDFSDK_InteractiveForm::SubmitFields( + const WideString& csDestination, + const std::vector<CPDF_FormField*>& fields, + bool bIncludeOrExclude, + bool bUrlEncoded) { ByteString textBuf = ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude); if (textBuf.IsEmpty()) return false; @@ -493,22 +499,22 @@ bool CPDFSDK_InterForm::SubmitFields(const WideString& csDestination, return true; } -ByteString CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( +ByteString CPDFSDK_InteractiveForm::ExportFieldsToFDFTextBuf( const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude) { - std::unique_ptr<CFDF_Document> pFDF = m_pInterForm->ExportToFDF( + std::unique_ptr<CFDF_Document> pFDF = m_pInteractiveForm->ExportToFDF( m_pFormFillEnv->JS_docGetFilePath(), fields, bIncludeOrExclude, false); return pFDF ? pFDF->WriteToString() : ByteString(); } -bool CPDFSDK_InterForm::SubmitForm(const WideString& sDestination, - bool bUrlEncoded) { +bool CPDFSDK_InteractiveForm::SubmitForm(const WideString& sDestination, + bool bUrlEncoded) { if (sDestination.IsEmpty()) return false; - std::unique_ptr<CFDF_Document> pFDFDoc = - m_pInterForm->ExportToFDF(m_pFormFillEnv->JS_docGetFilePath(), false); + std::unique_ptr<CFDF_Document> pFDFDoc = m_pInteractiveForm->ExportToFDF( + m_pFormFillEnv->JS_docGetFilePath(), false); if (!pFDFDoc) return false; @@ -524,29 +530,29 @@ bool CPDFSDK_InterForm::SubmitForm(const WideString& sDestination, return true; } -ByteString CPDFSDK_InterForm::ExportFormToFDFTextBuf() { - std::unique_ptr<CFDF_Document> pFDF = - m_pInterForm->ExportToFDF(m_pFormFillEnv->JS_docGetFilePath(), false); +ByteString CPDFSDK_InteractiveForm::ExportFormToFDFTextBuf() { + std::unique_ptr<CFDF_Document> pFDF = m_pInteractiveForm->ExportToFDF( + m_pFormFillEnv->JS_docGetFilePath(), false); return pFDF ? pFDF->WriteToString() : ByteString(); } -void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { +void CPDFSDK_InteractiveForm::DoAction_ResetForm(const CPDF_Action& action) { ASSERT(action.GetDict()); const CPDF_Dictionary* pActionDict = action.GetDict(); if (!pActionDict->KeyExist("Fields")) { - m_pInterForm->ResetForm(NotificationOption::kNotify); + m_pInteractiveForm->ResetForm(NotificationOption::kNotify); return; } CPDF_ActionFields af(&action); uint32_t dwFlags = action.GetFlags(); std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); - m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), - NotificationOption::kNotify); + m_pInteractiveForm->ResetForm(fields, !(dwFlags & 0x01), + NotificationOption::kNotify); } -std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( +std::vector<CPDF_FormField*> CPDFSDK_InteractiveForm::GetFieldFromObjects( const std::vector<const CPDF_Object*>& objects) const { std::vector<CPDF_FormField*> fields; for (const CPDF_Object* pObject : objects) { @@ -554,15 +560,15 @@ std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( continue; WideString csName = pObject->GetUnicodeText(); - CPDF_FormField* pField = m_pInterForm->GetField(0, csName); + CPDF_FormField* pField = m_pInteractiveForm->GetField(0, csName); if (pField) fields.push_back(pField); } return fields; } -bool CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField, - const WideString& csValue) { +bool CPDFSDK_InteractiveForm::BeforeValueChange(CPDF_FormField* pField, + const WideString& csValue) { FormFieldType fieldType = pField->GetFieldType(); if (!IsFormFieldTypeComboOrText(fieldType)) return true; @@ -571,7 +577,7 @@ bool CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField, return OnValidate(pField, csValue); } -void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { +void CPDFSDK_InteractiveForm::AfterValueChange(CPDF_FormField* pField) { #ifdef PDF_ENABLE_XFA SynchronizeField(pField); #endif // PDF_ENABLE_XFA @@ -585,8 +591,8 @@ void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { UpdateField(pField); } -bool CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, - const WideString& csValue) { +bool CPDFSDK_InteractiveForm::BeforeSelectionChange(CPDF_FormField* pField, + const WideString& csValue) { if (pField->GetFieldType() != FormFieldType::kListBox) return true; if (!OnKeyStrokeCommit(pField, csValue)) @@ -594,7 +600,7 @@ bool CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, return OnValidate(pField, csValue); } -void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { +void CPDFSDK_InteractiveForm::AfterSelectionChange(CPDF_FormField* pField) { if (pField->GetFieldType() != FormFieldType::kListBox) return; @@ -603,7 +609,7 @@ void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { UpdateField(pField); } -void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { +void CPDFSDK_InteractiveForm::AfterCheckedStatusChange(CPDF_FormField* pField) { FormFieldType fieldType = pField->GetFieldType(); if (fieldType != FormFieldType::kCheckBox && fieldType != FormFieldType::kRadioButton) @@ -613,11 +619,11 @@ void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { UpdateField(pField); } -void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) { +void CPDFSDK_InteractiveForm::AfterFormReset(CPDF_InteractiveForm* pForm) { OnCalculate(nullptr); } -bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) const { +bool CPDFSDK_InteractiveForm::IsNeedHighLight(FormFieldType fieldType) const { if (fieldType == FormFieldType::kUnknown) return false; @@ -632,14 +638,14 @@ bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) const { return m_NeedsHighlight[static_cast<size_t>(fieldType)]; } -void CPDFSDK_InterForm::RemoveAllHighLights() { +void CPDFSDK_InteractiveForm::RemoveAllHighLights() { std::fill(m_HighlightColor, m_HighlightColor + kFormFieldTypeCount, kWhiteBGR); std::fill(m_NeedsHighlight, m_NeedsHighlight + kFormFieldTypeCount, false); } -void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, - FormFieldType fieldType) { +void CPDFSDK_InteractiveForm::SetHighlightColor(FX_COLORREF clr, + FormFieldType fieldType) { if (fieldType == FormFieldType::kUnknown) return; @@ -647,14 +653,15 @@ void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, m_NeedsHighlight[static_cast<size_t>(fieldType)] = true; } -void CPDFSDK_InterForm::SetAllHighlightColors(FX_COLORREF clr) { +void CPDFSDK_InteractiveForm::SetAllHighlightColors(FX_COLORREF clr) { for (auto type : kFormFieldTypes) { m_HighlightColor[static_cast<size_t>(type)] = clr; m_NeedsHighlight[static_cast<size_t>(type)] = true; } } -FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(FormFieldType fieldType) { +FX_COLORREF CPDFSDK_InteractiveForm::GetHighlightColor( + FormFieldType fieldType) { if (fieldType == FormFieldType::kUnknown) return kWhiteBGR; diff --git a/fpdfsdk/cpdfsdk_interactiveform.h b/fpdfsdk/cpdfsdk_interactiveform.h index 06492e52a2..f629b91f78 100644 --- a/fpdfsdk/cpdfsdk_interactiveform.h +++ b/fpdfsdk/cpdfsdk_interactiveform.h @@ -21,7 +21,7 @@ class CPDF_Dictionary; class CPDF_FormControl; class CPDF_FormField; -class CPDF_InterForm; +class CPDF_InteractiveForm; class CPDF_Object; class CPDFSDK_FormFillEnvironment; @@ -30,12 +30,14 @@ class CPDFSDK_XFAWidget; class CXFA_FFWidget; #endif // PDF_ENABLE_XFA -class CPDFSDK_InterForm final : public IPDF_FormNotify { +class CPDFSDK_InteractiveForm final : public IPDF_FormNotify { public: - explicit CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv); - ~CPDFSDK_InterForm() override; + explicit CPDFSDK_InteractiveForm(CPDFSDK_FormFillEnvironment* pFormFillEnv); + ~CPDFSDK_InteractiveForm() override; - CPDF_InterForm* GetInterForm() const { return m_pInterForm.get(); } + CPDF_InteractiveForm* GetInteractiveForm() const { + return m_pInteractiveForm.get(); + } CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv.Get(); } @@ -108,13 +110,13 @@ class CPDFSDK_InterForm final : public IPDF_FormNotify { const WideString& csValue) override; void AfterSelectionChange(CPDF_FormField* pField) override; void AfterCheckedStatusChange(CPDF_FormField* pField) override; - void AfterFormReset(CPDF_InterForm* pForm) override; + void AfterFormReset(CPDF_InteractiveForm* pForm) override; int GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const; UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv; - std::unique_ptr<CPDF_InterForm> const m_pInterForm; + std::unique_ptr<CPDF_InteractiveForm> const m_pInteractiveForm; std::map<CPDF_FormControl*, CPDFSDK_Widget*> m_Map; #ifdef PDF_ENABLE_XFA std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap; diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 7a49dfe412..51056f4cc5 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -37,9 +37,9 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, ASSERT(m_page); CPDF_Page* pPDFPage = ToPDFPage(page); if (pPDFPage) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); - CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); - pPDFInterForm->FixPageFields(pPDFPage); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pPDFForm = pForm->GetInteractiveForm(); + pPDFForm->FixPageFields(pPDFPage); if (!page->AsXFAPage()) pPDFPage->SetView(this); } @@ -476,11 +476,11 @@ void CPDFSDK_PageView::LoadFXAnnots() { CPDF_Page* pPage = GetPDFPage(); ASSERT(pPage); - bool bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); + bool bUpdateAP = CPDF_InteractiveForm::IsUpdateAPEnabled(); // Disable the default AP construction. - CPDF_InterForm::SetUpdateAP(false); + CPDF_InteractiveForm::SetUpdateAP(false); m_pAnnotList = pdfium::MakeUnique<CPDF_AnnotList>(pPage); - CPDF_InterForm::SetUpdateAP(bUpdateAP); + CPDF_InteractiveForm::SetUpdateAP(bUpdateAP); const size_t nCount = m_pAnnotList->Count(); for (size_t i = 0; i < nCount; ++i) { diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index f41d230d1c..c30ce6ec86 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -43,8 +43,9 @@ CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, - CPDFSDK_InterForm* pInterForm) - : CPDFSDK_BAAnnot(pAnnot, pPageView), m_pInterForm(pInterForm) {} + CPDFSDK_InteractiveForm* pInteractiveForm) + : CPDFSDK_BAAnnot(pAnnot, pPageView), + m_pInteractiveForm(pInteractiveForm) {} CPDFSDK_Widget::~CPDFSDK_Widget() = default; @@ -359,9 +360,10 @@ int CPDFSDK_Widget::GetLayoutOrder() const { } int CPDFSDK_Widget::GetFieldFlags() const { - CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); + CPDF_InteractiveForm* pPDFInteractiveForm = + m_pInteractiveForm->GetInteractiveForm(); CPDF_FormControl* pFormControl = - pPDFInterForm->GetControlByDict(GetAnnotDict()); + pPDFInteractiveForm->GetControlByDict(GetAnnotDict()); CPDF_FormField* pFormField = pFormControl->GetField(); return pFormField->GetFieldFlags(); } @@ -376,8 +378,9 @@ CPDF_FormField* CPDFSDK_Widget::GetFormField() const { } CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { - CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); - return pPDFInterForm->GetControlByDict(GetAnnotDict()); + CPDF_InteractiveForm* pPDFInteractiveForm = + m_pInteractiveForm->GetInteractiveForm(); + return pPDFInteractiveForm->GetControlByDict(GetAnnotDict()); } int CPDFSDK_Widget::GetRotate() const { @@ -626,14 +629,14 @@ void CPDFSDK_Widget::ResetAppearance(Optional<WideString> sValue, Optional<WideString> CPDFSDK_Widget::OnFormat() { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField); - return m_pInterForm->OnFormat(pFormField); + return m_pInteractiveForm->OnFormat(pFormField); } void CPDFSDK_Widget::ResetFieldAppearance(bool bValueChanged) { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField); - m_pInterForm->ResetFieldAppearance(pFormField, pdfium::nullopt, - bValueChanged); + m_pInteractiveForm->ResetFieldAppearance(pFormField, pdfium::nullopt, + bValueChanged); } void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, @@ -661,13 +664,13 @@ void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, void CPDFSDK_Widget::UpdateField() { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField); - m_pInterForm->UpdateField(pFormField); + m_pInteractiveForm->UpdateField(pFormField); } void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView) { FormFieldType fieldType = GetFieldType(); - if (!m_pInterForm->IsNeedHighLight(fieldType)) + if (!m_pInteractiveForm->IsNeedHighLight(fieldType)) return; CFX_Matrix page2device; @@ -684,10 +687,11 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, rcDevice.top = tmp.y; rcDevice.Normalize(); - pDevice->FillRect(rcDevice.ToFxRect(), - AlphaAndColorRefToArgb( - static_cast<int>(m_pInterForm->GetHighlightAlpha()), - m_pInterForm->GetHighlightColor(fieldType))); + pDevice->FillRect( + rcDevice.ToFxRect(), + AlphaAndColorRefToArgb( + static_cast<int>(m_pInteractiveForm->GetHighlightAlpha()), + m_pInteractiveForm->GetHighlightColor(fieldType))); } CFX_FloatRect CPDFSDK_Widget::GetClientRect() const { diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index 283d244ca4..9954614e35 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -26,7 +26,7 @@ class CPDF_FormControl; class CPDF_FormField; class CPDF_RenderOptions; class CPDF_Stream; -class CPDFSDK_InterForm; +class CPDFSDK_InteractiveForm; class CPDFSDK_PageView; #ifdef PDF_ENABLE_XFA @@ -50,7 +50,7 @@ class CPDFSDK_Widget final : public CPDFSDK_BAAnnot { CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, - CPDFSDK_InterForm* pInterForm); + CPDFSDK_InteractiveForm* pInteractiveForm); ~CPDFSDK_Widget() override; bool IsSignatureWidget() const override; @@ -98,7 +98,9 @@ class CPDFSDK_Widget final : public CPDFSDK_BAAnnot { CPDFSDK_FieldAction* data, CPDFSDK_PageView* pPageView); - CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm.Get(); } + CPDFSDK_InteractiveForm* GetInteractiveForm() const { + return m_pInteractiveForm.Get(); + } CPDF_FormField* GetFormField() const; CPDF_FormControl* GetFormControl() const; @@ -130,7 +132,7 @@ class CPDFSDK_Widget final : public CPDFSDK_BAAnnot { WideString GetName() const; #endif // PDF_ENABLE_XFA - UnownedPtr<CPDFSDK_InterForm> const m_pInterForm; + UnownedPtr<CPDFSDK_InteractiveForm> const m_pInteractiveForm; bool m_bAppModified = false; uint32_t m_nAppearanceAge = 0; uint32_t m_nValueAge = 0; diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 70528d8d52..038890d67f 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -56,16 +56,15 @@ bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) { - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); - CPDF_FormControl* pCtrl = - pPDFInterForm->GetControlByDict(pAnnot->GetAnnotDict()); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pPDFForm = pForm->GetInteractiveForm(); + CPDF_FormControl* pCtrl = pPDFForm->GetControlByDict(pAnnot->GetAnnotDict()); if (!pCtrl) return nullptr; - CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); - pInterForm->AddMap(pCtrl, pWidget); - if (pPDFInterForm->NeedConstructAP()) + CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pForm); + pForm->AddMap(pCtrl, pWidget); + if (pPDFForm->NeedConstructAP()) pWidget->ResetAppearance(pdfium::nullopt, false); return pWidget; } @@ -82,9 +81,9 @@ void CPDFSDK_WidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { m_pFormFiller->OnDelete(pAnnot); std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot)); - CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pWidget->GetInteractiveForm(); CPDF_FormControl* pControl = pWidget->GetFormControl(); - pInterForm->RemoveMap(pControl); + pForm->RemoveMap(pControl); } void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp index 7c9089a29a..fc88f9c84e 100644 --- a/fpdfsdk/cpdfsdk_xfawidget.cpp +++ b/fpdfsdk/cpdfsdk_xfawidget.cpp @@ -11,9 +11,9 @@ CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPageView, - CPDFSDK_InterForm* pInterForm) + CPDFSDK_InteractiveForm* pInteractiveForm) : CPDFSDK_Annot(pPageView), - m_pInterForm(pInterForm), + m_pInteractiveForm(pInteractiveForm), m_hXFAWidget(pAnnot) {} CPDFSDK_XFAWidget::~CPDFSDK_XFAWidget() = default; diff --git a/fpdfsdk/cpdfsdk_xfawidget.h b/fpdfsdk/cpdfsdk_xfawidget.h index 2eaa29bb14..078f011593 100644 --- a/fpdfsdk/cpdfsdk_xfawidget.h +++ b/fpdfsdk/cpdfsdk_xfawidget.h @@ -12,7 +12,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "fpdfsdk/cpdfsdk_annot.h" -class CPDFSDK_InterForm; +class CPDFSDK_InteractiveForm; class CPDFSDK_PageView; class CXFA_FFWidget; @@ -20,7 +20,7 @@ class CPDFSDK_XFAWidget final : public CPDFSDK_Annot { public: CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPageView, - CPDFSDK_InterForm* pInterForm); + CPDFSDK_InteractiveForm* pInteractiveForm); ~CPDFSDK_XFAWidget() override; // CPDFSDK_Annot: @@ -29,10 +29,12 @@ class CPDFSDK_XFAWidget final : public CPDFSDK_Annot { CPDF_Annot::Subtype GetAnnotSubtype() const override; CFX_FloatRect GetRect() const override; - CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm.Get(); } + CPDFSDK_InteractiveForm* GetInteractiveForm() const { + return m_pInteractiveForm.Get(); + } private: - UnownedPtr<CPDFSDK_InterForm> const m_pInterForm; + UnownedPtr<CPDFSDK_InteractiveForm> const m_pInteractiveForm; UnownedPtr<CXFA_FFWidget> const m_hXFAWidget; }; diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index cc49c31d0b..20386f623f 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -40,9 +40,9 @@ CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPage) { - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm); - pInterForm->AddXFAMap(pAnnot, pWidget); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); + CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pForm); + pForm->AddXFAMap(pAnnot, pWidget); return pWidget; } @@ -70,7 +70,7 @@ void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { CPDFSDK_XFAWidget* pWidget = ToXFAWidget(pAnnot); - pWidget->GetInterForm()->RemoveXFAMap(pWidget->GetXFAWidget()); + pWidget->GetInteractiveForm()->RemoveXFAMap(pWidget->GetXFAWidget()); delete pWidget; } diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index d5ca80222f..3d5590af6d 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -702,8 +702,9 @@ void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Annot::ObservedPtr* pAnnot, CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot->Get()); if (pWidget) { - CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); - pInterForm->OnCalculate(pWidget->GetFormField()); + CPDFSDK_InteractiveForm* pForm = + pPageView->GetFormFillEnv()->GetInteractiveForm(); + pForm->OnCalculate(pWidget->GetFormField()); } m_bNotifying = false; } @@ -716,15 +717,16 @@ void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Annot::ObservedPtr* pAnnot, CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot->Get()); ASSERT(pWidget); - CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = + pPageView->GetFormFillEnv()->GetInteractiveForm(); - Optional<WideString> sValue = pInterForm->OnFormat(pWidget->GetFormField()); + Optional<WideString> sValue = pForm->OnFormat(pWidget->GetFormField()); if (!pAnnot->HasObservable()) return; if (sValue.has_value()) { - pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue, true); - pInterForm->UpdateField(pWidget->GetFormField()); + pForm->ResetFieldAppearance(pWidget->GetFormField(), sValue, true); + pForm->UpdateField(pWidget->GetFormField()); } m_bNotifying = false; diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp index 8595357488..757bb96b2e 100644 --- a/fpdfsdk/fpdf_annot.cpp +++ b/fpdfsdk/fpdf_annot.cpp @@ -873,8 +873,8 @@ FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot) { if (!pAnnotDict) return FPDF_FORMFLAG_NONE; - CPDF_InterForm interform(pPage->GetDocument()); - CPDF_FormField* pFormField = interform.GetFieldByDict(pAnnotDict); + CPDF_InteractiveForm interactive_form(pPage->GetDocument()); + CPDF_FormField* pFormField = interactive_form.GetFieldByDict(pAnnotDict); return pFormField ? pFormField->GetFieldFlags() : FPDF_FORMFLAG_NONE; } @@ -887,9 +887,9 @@ FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, if (!hHandle || !pPage) return nullptr; - CPDF_InterForm interform(pPage->GetDocument()); + CPDF_InteractiveForm interactive_form(pPage->GetDocument()); int annot_index = -1; - CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( + CPDF_FormControl* pFormCtrl = interactive_form.GetControlAtPoint( pPage, CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)), &annot_index); if (!pFormCtrl || annot_index == -1) diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp index 203017798b..5cecb6feef 100644 --- a/fpdfsdk/fpdf_formfill.cpp +++ b/fpdfsdk/fpdf_formfill.cpp @@ -144,10 +144,10 @@ static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT, namespace { -CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { +CPDFSDK_InteractiveForm* FormHandleToInteractiveForm(FPDF_FORMHANDLE hHandle) { CPDFSDK_FormFillEnvironment* pFormFillEnv = CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle); - return pFormFillEnv ? pFormFillEnv->GetInterForm() : nullptr; + return pFormFillEnv ? pFormFillEnv->GetInteractiveForm() : nullptr; } CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, @@ -232,8 +232,8 @@ FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, return -1; CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (pPage) { - CPDF_InterForm interform(pPage->GetDocument()); - CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( + CPDF_InteractiveForm interactive_form(pPage->GetDocument()); + CPDF_FormControl* pFormCtrl = interactive_form.GetControlAtPoint( pPage, CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)), nullptr); @@ -294,9 +294,9 @@ FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return -1; - CPDF_InterForm interform(pPage->GetDocument()); + CPDF_InteractiveForm interactive_form(pPage->GetDocument()); int z_order = -1; - (void)interform.GetControlAtPoint( + (void)interactive_form.GetControlAtPoint( pPage, CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)), &z_order); return z_order; @@ -585,31 +585,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color) { - CPDFSDK_InterForm* interForm = FormHandleToInterForm(hHandle); - if (!interForm) + CPDFSDK_InteractiveForm* pForm = FormHandleToInteractiveForm(hHandle); + if (!pForm) return; Optional<FormFieldType> cast_input = IntToFormFieldType(fieldType); if (!cast_input) return; - if (cast_input.value() == FormFieldType::kUnknown) { - interForm->SetAllHighlightColors(color); - } else { - interForm->SetHighlightColor(color, cast_input.value()); - } + if (cast_input.value() == FormFieldType::kUnknown) + pForm->SetAllHighlightColors(color); + else + pForm->SetHighlightColor(color, cast_input.value()); } FPDF_EXPORT void FPDF_CALLCONV FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha) { - if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) - pInterForm->SetHighlightAlpha(alpha); + if (CPDFSDK_InteractiveForm* pForm = FormHandleToInteractiveForm(hHandle)) + pForm->SetHighlightAlpha(alpha); } FPDF_EXPORT void FPDF_CALLCONV FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) { - if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) - pInterForm->RemoveAllHighLights(); + if (CPDFSDK_InteractiveForm* pForm = FormHandleToInteractiveForm(hHandle)) + pForm->RemoveAllHighLights(); } FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 8c89895292..6cf4bff833 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -380,14 +380,16 @@ void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, bool CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return false; - return m_pContext->GetFormFillEnv()->GetInterForm()->IsXfaCalculateEnabled(); + auto* pForm = m_pContext->GetFormFillEnv()->GetInteractiveForm(); + return pForm->IsXfaCalculateEnabled(); } void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return; - m_pContext->GetFormFillEnv()->GetInterForm()->XfaEnableCalculate(bEnabled); + m_pContext->GetFormFillEnv()->GetInteractiveForm()->XfaEnableCalculate( + bEnabled); } void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) { @@ -528,8 +530,9 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, bool CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return false; - auto* pInterform = m_pContext->GetFormFillEnv()->GetInterForm(); - return pInterform->IsXfaValidationsEnabled(); + + auto* pForm = m_pContext->GetFormFillEnv()->GetInteractiveForm(); + return pForm->IsXfaValidationsEnabled(); } void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, @@ -537,7 +540,7 @@ void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return; - m_pContext->GetFormFillEnv()->GetInterForm()->XfaSetValidationsEnabled( + m_pContext->GetFormFillEnv()->GetInteractiveForm()->XfaSetValidationsEnabled( bEnabled); } @@ -592,10 +595,10 @@ FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return 0; - CPDFSDK_InterForm* pInterForm = m_pContext->GetFormFillEnv()->GetInterForm(); - return AlphaAndColorRefToArgb( - pInterForm->GetHighlightAlpha(), - pInterForm->GetHighlightColor(FormFieldType::kXFA)); + CPDFSDK_InteractiveForm* pForm = + m_pContext->GetFormFillEnv()->GetInteractiveForm(); + return AlphaAndColorRefToArgb(pForm->GetHighlightAlpha(), + pForm->GetHighlightColor(FormFieldType::kXFA)); } #ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp index dd86ef5d32..d57619e82f 100644 --- a/fpdfsdk/pwl/cpwl_appstream.cpp +++ b/fpdfsdk/pwl/cpwl_appstream.cpp @@ -1236,7 +1236,7 @@ void CPWL_AppStream::SetAsPushButton() { CBA_FontMap font_map( widget_.Get(), - widget_->GetInterForm()->GetFormFillEnv()->GetSysHandler()); + widget_->GetInteractiveForm()->GetFormFillEnv()->GetSysHandler()); font_map.SetAPType("N"); ByteString csAP = @@ -1593,7 +1593,7 @@ void CPWL_AppStream::SetAsComboBox(Optional<WideString> sValue) { // Font map must outlive |pEdit|. CBA_FontMap font_map( widget_.Get(), - widget_->GetInterForm()->GetFormFillEnv()->GetSysHandler()); + widget_->GetInteractiveForm()->GetFormFillEnv()->GetSysHandler()); auto pEdit = pdfium::MakeUnique<CPWL_EditImpl>(); pEdit->EnableRefresh(false); @@ -1660,7 +1660,7 @@ void CPWL_AppStream::SetAsListBox() { // Font map must outlive |pEdit|. CBA_FontMap font_map( widget_.Get(), - widget_->GetInterForm()->GetFormFillEnv()->GetSysHandler()); + widget_->GetInteractiveForm()->GetFormFillEnv()->GetSysHandler()); auto pEdit = pdfium::MakeUnique<CPWL_EditImpl>(); pEdit->EnableRefresh(false); @@ -1745,7 +1745,7 @@ void CPWL_AppStream::SetAsTextField(Optional<WideString> sValue) { // Font map must outlive |pEdit|. CBA_FontMap font_map( widget_.Get(), - widget_->GetInterForm()->GetFormFillEnv()->GetSysHandler()); + widget_->GetInteractiveForm()->GetFormFillEnv()->GetSysHandler()); auto pEdit = pdfium::MakeUnique<CPWL_EditImpl>(); pEdit->EnableRefresh(false); |