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 | |
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>
31 files changed, 366 insertions, 340 deletions
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 19a835297c..909431caf3 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -185,7 +185,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) pAnnots->ConvertToIndirectObjectAt(i, m_pDocument); m_AnnotList.push_back(pdfium::MakeUnique<CPDF_Annot>(pDict, m_pDocument)); if (bRegenerateAP && subtype == "Widget" && - CPDF_InterForm::IsUpdateAPEnabled() && !pDict->GetDictFor("AP")) { + CPDF_InteractiveForm::IsUpdateAPEnabled() && !pDict->GetDictFor("AP")) { GenerateAP(m_pDocument, pDict); } } diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h index b89a08be18..7288651a73 100644 --- a/core/fpdfdoc/cpdf_formcontrol.h +++ b/core/fpdfdoc/cpdf_formcontrol.h @@ -32,7 +32,7 @@ class CFX_RenderDevice; class CPDF_Dictionary; class CPDF_Font; class CPDF_FormField; -class CPDF_InterForm; +class CPDF_InteractiveForm; class CPDF_OCContext; class CPDF_RenderOptions; class CPDF_Stream; @@ -45,7 +45,9 @@ class CPDF_FormControl { ~CPDF_FormControl(); CPDF_FormField::Type GetType() const { return m_pField->GetType(); } - const CPDF_InterForm* GetInterForm() const { return m_pForm.Get(); } + const CPDF_InteractiveForm* GetInteractiveForm() const { + return m_pForm.Get(); + } CPDF_FormField* GetField() const { return m_pField; } CPDF_Dictionary* GetWidget() const { return m_pWidgetDict.Get(); } CFX_FloatRect GetRect() const; @@ -115,7 +117,7 @@ class CPDF_FormControl { CPDF_FormField* const m_pField; UnownedPtr<CPDF_Dictionary> const m_pWidgetDict; - UnownedPtr<const CPDF_InterForm> const m_pForm; + UnownedPtr<const CPDF_InteractiveForm> const m_pForm; }; #endif // CORE_FPDFDOC_CPDF_FORMCONTROL_H_ diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 4b1b9b401c..b149ef6e2f 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -102,7 +102,8 @@ WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { return full_name; } -CPDF_FormField::CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict) +CPDF_FormField::CPDF_FormField(CPDF_InteractiveForm* pForm, + CPDF_Dictionary* pDict) : m_pForm(pForm), m_pDict(pDict) { InitFieldFlags(); } diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index 13771fc983..8e7d9e446c 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -20,7 +20,7 @@ class CPDF_Dictionary; class CPDF_Font; class CPDF_FormControl; -class CPDF_InterForm; +class CPDF_InteractiveForm; class CPDF_Object; class CPDF_String; @@ -98,7 +98,7 @@ class CPDF_FormField { Sign }; - CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); + CPDF_FormField(CPDF_InteractiveForm* pForm, CPDF_Dictionary* pDict); ~CPDF_FormField(); WideString GetFullName() const; @@ -171,7 +171,7 @@ class CPDF_FormField { CPDF_Font* GetFont() const { return m_pFont.Get(); } CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } - CPDF_InterForm* GetForm() const { return m_pForm.Get(); } + CPDF_InteractiveForm* GetForm() const { return m_pForm.Get(); } WideString GetCheckValue(bool bDefault) const; @@ -206,9 +206,9 @@ class CPDF_FormField { bool m_bRequired = false; bool m_bNoExport = false; - UnownedPtr<CPDF_InterForm> const m_pForm; + UnownedPtr<CPDF_InteractiveForm> const m_pForm; UnownedPtr<CPDF_Dictionary> const m_pDict; - // Owned by InterForm parent. + // Owned by InteractiveForm parent. std::vector<UnownedPtr<CPDF_FormControl>> m_ControlList; float m_FontSize = 0; UnownedPtr<CPDF_Font> m_pFont; diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp index e05979d341..50cdb2eda6 100644 --- a/core/fpdfdoc/cpdf_interactiveform.cpp +++ b/core/fpdfdoc/cpdf_interactiveform.cpp @@ -87,16 +87,17 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { ByteString csDA; if (!pFormDict->KeyExist("DR")) { ByteString csBaseName; - uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); - CPDF_Font* pFont = CPDF_InterForm::AddStandardFont( + uint8_t charSet = CPDF_InteractiveForm::GetNativeCharSet(); + CPDF_Font* pFont = CPDF_InteractiveForm::AddStandardFont( pDocument, CFX_Font::kDefaultAnsiFontName); if (pFont) AddFont(pFormDict, pDocument, pFont, &csBaseName); if (charSet != FX_CHARSET_ANSI) { - ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); + ByteString csFontName = + CPDF_InteractiveForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != CFX_Font::kDefaultAnsiFontName) { - pFont = CPDF_InterForm::AddNativeFont(pDocument); + pFont = CPDF_InteractiveForm::AddNativeFont(pDocument); if (pFont) { csBaseName.clear(); AddFont(pFormDict, pDocument, pFont, &csBaseName); @@ -299,12 +300,12 @@ CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, *csNameTag = std::move(csTemp); return pFont; } - ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); + ByteString csFontName = CPDF_InteractiveForm::GetNativeFont(charSet, nullptr); if (!csFontName.IsEmpty() && FindFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) { return pFont; } - pFont = CPDF_InterForm::AddNativeFont(charSet, pDocument); + pFont = CPDF_InteractiveForm::AddNativeFont(charSet, pDocument); if (pFont) AddFont(pFormDict, pDocument, pFont, csNameTag); @@ -564,19 +565,19 @@ CFieldTree::Node* CFieldTree::FindNode(const WideString& full_name) { return pNode; } -CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, - CPDF_Document* pDocument, - ByteString* csNameTag) { - uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); +CPDF_Font* AddNativeInteractiveFormFont(CPDF_Dictionary*& pFormDict, + CPDF_Document* pDocument, + ByteString* csNameTag) { + uint8_t charSet = CPDF_InteractiveForm::GetNativeCharSet(); return AddNativeFont(pFormDict, pDocument, charSet, csNameTag); } // static -uint8_t CPDF_InterForm::GetNativeCharSet() { +uint8_t CPDF_InteractiveForm::GetNativeCharSet() { return FX_GetCharsetFromCodePage(FXSYS_GetACP()); } -CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument) +CPDF_InteractiveForm::CPDF_InteractiveForm(CPDF_Document* pDocument) : m_pDocument(pDocument), m_pFieldTree(pdfium::MakeUnique<CFieldTree>()) { CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); if (!pRoot) @@ -594,20 +595,20 @@ CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument) LoadField(pFields->GetDictAt(i), 0); } -CPDF_InterForm::~CPDF_InterForm() {} +CPDF_InteractiveForm::~CPDF_InteractiveForm() = default; -bool CPDF_InterForm::s_bUpdateAP = true; +bool CPDF_InteractiveForm::s_bUpdateAP = true; -bool CPDF_InterForm::IsUpdateAPEnabled() { +bool CPDF_InteractiveForm::IsUpdateAPEnabled() { return s_bUpdateAP; } -void CPDF_InterForm::SetUpdateAP(bool bUpdateAP) { +void CPDF_InteractiveForm::SetUpdateAP(bool bUpdateAP) { s_bUpdateAP = bUpdateAP; } -CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument, - ByteString csFontName) { +CPDF_Font* CPDF_InteractiveForm::AddStandardFont(CPDF_Document* pDocument, + ByteString csFontName) { if (!pDocument || csFontName.IsEmpty()) return nullptr; @@ -618,7 +619,8 @@ CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument, return pDocument->AddStandardFont(csFontName.c_str(), &encoding); } -ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { +ByteString CPDF_InteractiveForm::GetNativeFont(uint8_t charSet, + void* pLogFont) { ByteString csFontName; #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ LOGFONTA lf = {}; @@ -656,8 +658,8 @@ ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { return csFontName; } -CPDF_Font* CPDF_InterForm::AddNativeFont(uint8_t charSet, - CPDF_Document* pDocument) { +CPDF_Font* CPDF_InteractiveForm::AddNativeFont(uint8_t charSet, + CPDF_Document* pDocument) { if (!pDocument) return nullptr; @@ -673,11 +675,11 @@ CPDF_Font* CPDF_InterForm::AddNativeFont(uint8_t charSet, return nullptr; } -CPDF_Font* CPDF_InterForm::AddNativeFont(CPDF_Document* pDocument) { +CPDF_Font* CPDF_InteractiveForm::AddNativeFont(CPDF_Document* pDocument) { return pDocument ? AddNativeFont(GetNativeCharSet(), pDocument) : nullptr; } -size_t CPDF_InterForm::CountFields(const WideString& csFieldName) const { +size_t CPDF_InteractiveForm::CountFields(const WideString& csFieldName) const { if (csFieldName.IsEmpty()) return m_pFieldTree->m_Root.CountFields(); @@ -685,8 +687,9 @@ size_t CPDF_InterForm::CountFields(const WideString& csFieldName) const { return pNode ? pNode->CountFields() : 0; } -CPDF_FormField* CPDF_InterForm::GetField(uint32_t index, - const WideString& csFieldName) const { +CPDF_FormField* CPDF_InteractiveForm::GetField( + uint32_t index, + const WideString& csFieldName) const { if (csFieldName.IsEmpty()) return m_pFieldTree->m_Root.GetFieldAtIndex(index); @@ -694,7 +697,7 @@ CPDF_FormField* CPDF_InterForm::GetField(uint32_t index, return pNode ? pNode->GetFieldAtIndex(index) : nullptr; } -CPDF_FormField* CPDF_InterForm::GetFieldByDict( +CPDF_FormField* CPDF_InteractiveForm::GetFieldByDict( CPDF_Dictionary* pFieldDict) const { if (!pFieldDict) return nullptr; @@ -703,10 +706,11 @@ CPDF_FormField* CPDF_InterForm::GetFieldByDict( return m_pFieldTree->GetField(csWName); } -CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, - const CFX_PointF& point, +CPDF_FormControl* CPDF_InteractiveForm::GetControlAtPoint( + CPDF_Page* pPage, + const CFX_PointF& point, - int* z_order) const { + int* z_order) const { CPDF_Array* pAnnotList = pPage->GetDict()->GetArrayFor("Annots"); if (!pAnnotList) return nullptr; @@ -732,17 +736,17 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, return nullptr; } -CPDF_FormControl* CPDF_InterForm::GetControlByDict( +CPDF_FormControl* CPDF_InteractiveForm::GetControlByDict( const CPDF_Dictionary* pWidgetDict) const { const auto it = m_ControlMap.find(pWidgetDict); return it != m_ControlMap.end() ? it->second.get() : nullptr; } -bool CPDF_InterForm::NeedConstructAP() const { +bool CPDF_InteractiveForm::NeedConstructAP() const { return m_pFormDict && m_pFormDict->GetBooleanFor("NeedAppearances", false); } -int CPDF_InterForm::CountFieldsInCalculationOrder() { +int CPDF_InteractiveForm::CountFieldsInCalculationOrder() { if (!m_pFormDict) return 0; @@ -750,7 +754,7 @@ int CPDF_InterForm::CountFieldsInCalculationOrder() { return pArray ? pArray->GetCount() : 0; } -CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { +CPDF_FormField* CPDF_InteractiveForm::GetFieldInCalculationOrder(int index) { if (!m_pFormDict || index < 0) return nullptr; @@ -762,7 +766,8 @@ CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { return pElement ? GetFieldByDict(pElement) : nullptr; } -int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { +int CPDF_InteractiveForm::FindFieldInCalculationOrder( + const CPDF_FormField* pField) { if (!m_pFormDict || !pField) return -1; @@ -778,23 +783,23 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { return -1; } -CPDF_Font* CPDF_InterForm::GetFormFont(ByteString csNameTag) const { +CPDF_Font* CPDF_InteractiveForm::GetFormFont(ByteString csNameTag) const { return GetFont(m_pFormDict.Get(), m_pDocument.Get(), csNameTag); } -CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() const { +CPDF_DefaultAppearance CPDF_InteractiveForm::GetDefaultAppearance() const { if (!m_pFormDict) return CPDF_DefaultAppearance(); return CPDF_DefaultAppearance(m_pFormDict->GetStringFor("DA")); } -int CPDF_InterForm::GetFormAlignment() const { +int CPDF_InteractiveForm::GetFormAlignment() const { return m_pFormDict ? m_pFormDict->GetIntegerFor("Q", 0) : 0; } -void CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields, - bool bIncludeOrExclude, - NotificationOption notify) { +void CPDF_InteractiveForm::ResetForm(const std::vector<CPDF_FormField*>& fields, + bool bIncludeOrExclude, + NotificationOption notify) { size_t nCount = m_pFieldTree->m_Root.CountFields(); for (size_t i = 0; i < nCount; ++i) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i); @@ -808,7 +813,7 @@ void CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields, m_pFormNotify->AfterFormReset(this); } -void CPDF_InterForm::ResetForm(NotificationOption notify) { +void CPDF_InteractiveForm::ResetForm(NotificationOption notify) { size_t nCount = m_pFieldTree->m_Root.CountFields(); for (size_t i = 0; i < nCount; ++i) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i); @@ -821,7 +826,7 @@ void CPDF_InterForm::ResetForm(NotificationOption notify) { m_pFormNotify->AfterFormReset(this); } -void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { +void CPDF_InteractiveForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { if (nLevel > nMaxRecursion) return; if (!pFieldDict) @@ -851,11 +856,11 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { } } -bool CPDF_InterForm::HasXFAForm() const { +bool CPDF_InteractiveForm::HasXFAForm() const { return m_pFormDict && m_pFormDict->GetArrayFor("XFA"); } -void CPDF_InterForm::FixPageFields(CPDF_Page* pPage) { +void CPDF_InteractiveForm::FixPageFields(CPDF_Page* pPage) { CPDF_Dictionary* pPageDict = pPage->GetDict(); if (!pPageDict) return; @@ -871,7 +876,7 @@ void CPDF_InterForm::FixPageFields(CPDF_Page* pPage) { } } -void CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { +void CPDF_InteractiveForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { if (!pFieldDict->KeyExist("FT")) { // Key "FT" is required for terminal fields, it is also inheritable. CPDF_Dictionary* pParentDict = pFieldDict->GetDictFor("Parent"); @@ -940,8 +945,9 @@ void CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { } } -CPDF_FormControl* CPDF_InterForm::AddControl(CPDF_FormField* pField, - CPDF_Dictionary* pWidgetDict) { +CPDF_FormControl* CPDF_InteractiveForm::AddControl( + CPDF_FormField* pField, + CPDF_Dictionary* pWidgetDict) { const auto it = m_ControlMap.find(pWidgetDict); if (it != m_ControlMap.end()) return it->second.get(); @@ -953,7 +959,7 @@ CPDF_FormControl* CPDF_InterForm::AddControl(CPDF_FormField* pField, return pControl; } -bool CPDF_InterForm::CheckRequiredFields( +bool CPDF_InteractiveForm::CheckRequiredFields( const std::vector<CPDF_FormField*>* fields, bool bIncludeOrExclude) const { size_t nCount = m_pFieldTree->m_Root.CountFields(); @@ -982,7 +988,7 @@ bool CPDF_InterForm::CheckRequiredFields( return true; } -std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( +std::unique_ptr<CFDF_Document> CPDF_InteractiveForm::ExportToFDF( const WideString& pdf_path, bool bSimpleFileSpec) const { std::vector<CPDF_FormField*> fields; @@ -992,7 +998,7 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec); } -std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( +std::unique_ptr<CFDF_Document> CPDF_InteractiveForm::ExportToFDF( const WideString& pdf_path, const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude, @@ -1061,6 +1067,6 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( return pDoc; } -void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { +void CPDF_InteractiveForm::SetFormNotify(IPDF_FormNotify* pNotify) { m_pFormNotify = pNotify; } diff --git a/core/fpdfdoc/cpdf_interactiveform.h b/core/fpdfdoc/cpdf_interactiveform.h index ebbbe2778c..1b68852d48 100644 --- a/core/fpdfdoc/cpdf_interactiveform.h +++ b/core/fpdfdoc/cpdf_interactiveform.h @@ -28,14 +28,14 @@ class CPDF_Object; class CPDF_Page; class IPDF_FormNotify; -CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, - CPDF_Document* pDocument, - ByteString* csNameTag); +CPDF_Font* AddNativeInteractiveFormFont(CPDF_Dictionary*& pFormDict, + CPDF_Document* pDocument, + ByteString* csNameTag); -class CPDF_InterForm { +class CPDF_InteractiveForm { public: - explicit CPDF_InterForm(CPDF_Document* pDocument); - ~CPDF_InterForm(); + explicit CPDF_InteractiveForm(CPDF_Document* pDocument); + ~CPDF_InteractiveForm(); static void SetUpdateAP(bool bUpdateAP); static bool IsUpdateAPEnabled(); diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 7d414f6c8d..c235505369 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -33,7 +33,8 @@ CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, return nullptr; CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); - CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); + CPDF_Font* pPDFFont = + AddNativeInteractiveFormFont(pFormDict, pDoc, sSysFontAlias); if (!pPDFFont) return nullptr; diff --git a/core/fpdfdoc/ipdf_formnotify.h b/core/fpdfdoc/ipdf_formnotify.h index 7e11ecbd12..6a72c68d70 100644 --- a/core/fpdfdoc/ipdf_formnotify.h +++ b/core/fpdfdoc/ipdf_formnotify.h @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_string.h" class CPDF_FormField; -class CPDF_InterForm; +class CPDF_InteractiveForm; class IPDF_FormNotify { public: @@ -25,7 +25,7 @@ class IPDF_FormNotify { virtual void AfterSelectionChange(CPDF_FormField* pField) = 0; virtual void AfterCheckedStatusChange(CPDF_FormField* pField) = 0; - virtual void AfterFormReset(CPDF_InterForm* pForm) = 0; + virtual void AfterFormReset(CPDF_InteractiveForm* pForm) = 0; }; #endif // CORE_FPDFDOC_IPDF_FORMNOTIFY_H_ 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); diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index c51bd9dca2..97ff37872a 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -128,7 +128,8 @@ CJS_Result CJS_App::get_calculate(CJS_Runtime* pRuntime) { CJS_Result CJS_App::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_bCalculate = pRuntime->ToBoolean(vp); - pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate); + pRuntime->GetFormFillEnv()->GetInteractiveForm()->EnableCalculate( + m_bCalculate); return CJS_Result::Success(); } diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 483124acf4..6e2f2da6c6 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -209,7 +209,7 @@ CJS_Result CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDF_InterForm* pPDFForm = GetCoreInterForm(); + CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); return CJS_Result::Success(pRuntime->NewNumber( static_cast<int>(pPDFForm->CountFields(WideString())))); } @@ -319,7 +319,7 @@ CJS_Result CJS_Document::getField( return CJS_Result::Failure(JSMessage::kBadObjectError); WideString wideName = pRuntime->ToWideString(params[0]); - CPDF_InterForm* pPDFForm = GetCoreInterForm(); + CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); if (pPDFForm->CountFields(wideName) <= 0) return CJS_Result::Success(pRuntime->NewUndefined()); @@ -350,7 +350,7 @@ CJS_Result CJS_Document::getNthFieldName( if (nIndex < 0) return CJS_Result::Failure(JSMessage::kValueError); - CPDF_InterForm* pPDFForm = GetCoreInterForm(); + CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString()); if (!pField) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -390,8 +390,8 @@ CJS_Result CJS_Document::mailForm( if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return CJS_Result::Failure(JSMessage::kPermissionError); - CPDFSDK_InterForm* pInterForm = GetSDKInterForm(); - ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf(); + CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); + ByteString sTextBuf = pInteractiveForm->ExportFormToFDFTextBuf(); if (sTextBuf.GetLength() == 0) return CJS_Result::Failure(L"Bad FDF format."); @@ -486,9 +486,9 @@ CJS_Result CJS_Document::removeField( return CJS_Result::Failure(JSMessage::kPermissionError); WideString sFieldName = pRuntime->ToWideString(params[0]); - CPDFSDK_InterForm* pInterForm = GetSDKInterForm(); + CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; - pInterForm->GetWidgets(sFieldName, &widgets); + pInteractiveForm->GetWidgets(sFieldName, &widgets); if (widgets.empty()) return CJS_Result::Success(); @@ -533,7 +533,7 @@ CJS_Result CJS_Document::resetForm( return CJS_Result::Failure(JSMessage::kPermissionError); } - CPDF_InterForm* pPDFForm = GetCoreInterForm(); + CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); if (params.empty()) { pPDFForm->ResetForm(NotificationOption::kNotify); m_pFormFillEnv->SetChangeMark(); @@ -609,11 +609,11 @@ CJS_Result CJS_Document::submitForm( aFields = pRuntime->ToArray(pRuntime->GetObjectProperty(pObj, L"aFields")); } - CPDF_InterForm* pPDFForm = GetCoreInterForm(); + CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); if (pRuntime->GetArrayLength(aFields) == 0 && bEmpty) { if (pPDFForm->CheckRequiredFields(nullptr, true)) { pRuntime->BeginBlock(); - GetSDKInterForm()->SubmitForm(strURL, false); + GetSDKInteractiveForm()->SubmitForm(strURL, false); pRuntime->EndBlock(); } return CJS_Result::Success(); @@ -634,7 +634,7 @@ CJS_Result CJS_Document::submitForm( if (pPDFForm->CheckRequiredFields(&fieldObjects, true)) { pRuntime->BeginBlock(); - GetSDKInterForm()->SubmitFields(strURL, fieldObjects, true, !bFDF); + GetSDKInteractiveForm()->SubmitFields(strURL, fieldObjects, true, !bFDF); pRuntime->EndBlock(); } return CJS_Result::Success(); @@ -970,9 +970,9 @@ CJS_Result CJS_Document::get_calculate(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = GetSDKInterForm(); + CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); return CJS_Result::Success( - pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled())); + pRuntime->NewBoolean(!!pInteractiveForm->IsCalculateEnabled())); } CJS_Result CJS_Document::set_calculate(CJS_Runtime* pRuntime, @@ -980,8 +980,8 @@ CJS_Result CJS_Document::set_calculate(CJS_Runtime* pRuntime, if (!m_pFormFillEnv) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = GetSDKInterForm(); - pInterForm->EnableCalculate(pRuntime->ToBoolean(vp)); + CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); + pInteractiveForm->EnableCalculate(pRuntime->ToBoolean(vp)); return CJS_Result::Success(); } @@ -1262,7 +1262,7 @@ CJS_Result CJS_Document::calculateNow( return CJS_Result::Failure(JSMessage::kPermissionError); } - GetSDKInterForm()->OnCalculate(nullptr); + GetSDKInteractiveForm()->OnCalculate(nullptr); return CJS_Result::Success(); } @@ -1479,10 +1479,10 @@ void CJS_Document::DoFieldDelay(const WideString& sFieldName, CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); } -CPDF_InterForm* CJS_Document::GetCoreInterForm() { - return GetSDKInterForm()->GetInterForm(); +CPDF_InteractiveForm* CJS_Document::GetCoreInteractiveForm() { + return GetSDKInteractiveForm()->GetInteractiveForm(); } -CPDFSDK_InterForm* CJS_Document::GetSDKInterForm() { - return m_pFormFillEnv->GetInterForm(); +CPDFSDK_InteractiveForm* CJS_Document::GetSDKInteractiveForm() { + return m_pFormFillEnv->GetInteractiveForm(); } diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h index b415c82868..5232803989 100644 --- a/fxjs/cjs_document.h +++ b/fxjs/cjs_document.h @@ -14,8 +14,8 @@ #include "core/fxcrt/observable.h" #include "fxjs/js_define.h" -class CPDFSDK_InterForm; -class CPDF_InterForm; +class CPDFSDK_InteractiveForm; +class CPDF_InteractiveForm; class CPDF_TextObject; struct CJS_DelayData; @@ -306,8 +306,8 @@ class CJS_Document final : public CJS_Object, public Observable<CJS_Document> { v8::Local<v8::Value> vp, const ByteString& propName); - CPDF_InterForm* GetCoreInterForm(); - CPDFSDK_InterForm* GetSDKInterForm(); + CPDF_InteractiveForm* GetCoreInteractiveForm(); + CPDFSDK_InteractiveForm* GetSDKInteractiveForm(); WideString m_cwBaseURL; CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv; diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index 628eb440df..ca8c62451c 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -45,11 +45,11 @@ void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, bool bChangeMark, bool bResetAP, bool bRefresh) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); if (bResetAP) { std::vector<CPDFSDK_Annot::ObservedPtr> widgets; - pInterForm->GetWidgets(pFormField, &widgets); + pForm->GetWidgets(pFormField, &widgets); if (IsComboBoxOrTextField(pFormField)) { for (auto& pObserved : widgets) { @@ -74,16 +74,16 @@ void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, // to be removed from the list. We need to call |GetWidgets| again to be // sure none of the widgets have been deleted. std::vector<CPDFSDK_Annot::ObservedPtr> widgets; - pInterForm->GetWidgets(pFormField, &widgets); + pForm->GetWidgets(pFormField, &widgets); // TODO(dsinclair): Determine if all widgets share the same - // CPDFSDK_InterForm. If that's the case, we can move the code to + // CPDFSDK_InteractiveForm. If that's the case, we can move the code to // |GetFormFillEnv| out of the loop. for (auto& pObserved : widgets) { if (pObserved) { CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pObserved.Get()); - pWidget->GetInterForm()->GetFormFillEnv()->UpdateAllViews(nullptr, - pWidget); + pWidget->GetInteractiveForm()->GetFormFillEnv()->UpdateAllViews( + nullptr, pWidget); } } } @@ -99,7 +99,7 @@ void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv, bool bRefresh) { ASSERT(pFormControl); - CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl); if (pWidget) { @@ -120,8 +120,8 @@ void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv, } if (bRefresh) { - CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); - pInterForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget); + CPDFSDK_InteractiveForm* pWidgetForm = pWidget->GetInteractiveForm(); + pWidgetForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget); } } @@ -133,10 +133,10 @@ std::vector<CPDF_FormField*> GetFormFieldsForName( CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& csFieldName) { std::vector<CPDF_FormField*> fields; - CPDFSDK_InterForm* pReaderInterForm = pFormFillEnv->GetInterForm(); - CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); - for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { - if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) + CPDFSDK_InteractiveForm* pReaderForm = pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pForm = pReaderForm->GetInteractiveForm(); + for (int i = 0, sz = pForm->CountFields(csFieldName); i < sz; ++i) { + if (CPDF_FormField* pFormField = pForm->GetField(i, csFieldName)) fields.push_back(pFormField); } return fields; @@ -202,13 +202,12 @@ void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, std::vector<CPDF_FormField*> FieldArray = GetFormFieldsForName(pFormFillEnv, swFieldName); - auto* pInterForm = pFormFillEnv->GetInterForm(); + auto* pForm = pFormFillEnv->GetInteractiveForm(); for (CPDF_FormField* pFormField : FieldArray) { if (nControlIndex < 0) { bool bSet = false; for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { - CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(pFormField->GetControl(i)); + CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormField->GetControl(i)); if (pWidget) { if (pWidget->GetBorderStyle() != nBorderStyle) { pWidget->SetBorderStyle(nBorderStyle); @@ -223,7 +222,7 @@ void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, return; if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex)) { - CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); + CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl); if (pWidget) { if (pWidget->GetBorderStyle() != nBorderStyle) { pWidget->SetBorderStyle(nBorderStyle); @@ -266,7 +265,7 @@ void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& swFieldName, int nControlIndex, int number) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFieldsForName(pFormFillEnv, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { @@ -276,7 +275,7 @@ void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormControl* pFormControl = pFormField->GetControl(i); ASSERT(pFormControl); - CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); + CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl); if (SetWidgetDisplayStatus(pWidget, number)) bAnySet = true; } @@ -291,7 +290,7 @@ void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, if (!pFormControl) return; - CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); + CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl); if (SetWidgetDisplayStatus(pWidget, number)) UpdateFormControl(pFormFillEnv, pFormControl, true, false, true); } @@ -310,7 +309,7 @@ void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& swFieldName, int nControlIndex, int number) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFieldsForName(pFormFillEnv, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { @@ -320,7 +319,7 @@ void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormControl* pFormControl = pFormField->GetControl(i); ASSERT(pFormControl); - if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { + if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { if (number != pWidget->GetBorderWidth()) { pWidget->SetBorderWidth(number); bSet = true; @@ -334,7 +333,7 @@ void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, return; if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex)) { - if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { + if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { if (number != pWidget->GetBorderWidth()) { pWidget->SetBorderWidth(number); UpdateFormControl(pFormFillEnv, pFormControl, true, true, true); @@ -349,7 +348,7 @@ void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& swFieldName, int nControlIndex, const CFX_FloatRect& rect) { - CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = pFormFillEnv->GetInteractiveForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFieldsForName(pFormFillEnv, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { @@ -359,7 +358,7 @@ void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormControl* pFormControl = pFormField->GetControl(i); ASSERT(pFormControl); - if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { + if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { CFX_FloatRect crRect = rect; CPDF_Page* pPDFPage = pWidget->GetPDFPage(); @@ -386,7 +385,7 @@ void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, return; if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex)) { - if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { + if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { CFX_FloatRect crRect = rect; CPDF_Page* pPDFPage = pWidget->GetPDFPage(); crRect.Intersect(pPDFPage->GetBBox()); @@ -608,12 +607,12 @@ bool CJS_Field::AttachField(CJS_Document* pDocument, m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY); - CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); - CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); + CPDFSDK_InteractiveForm* pRDForm = m_pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pForm = pRDForm->GetInteractiveForm(); WideString swFieldNameTemp = csFieldName; swFieldNameTemp.Replace(L"..", L"."); - if (pInterForm->CountFields(swFieldNameTemp) <= 0) { + if (pForm->CountFields(swFieldNameTemp) <= 0) { std::wstring strFieldName; int iControlNo = -1; ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); @@ -700,7 +699,7 @@ CJS_Result CJS_Field::get_border_style(CJS_Runtime* pRuntime) { if (!pFormField) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_Widget* pWidget = m_pFormFillEnv->GetInterForm()->GetWidget( + CPDFSDK_Widget* pWidget = m_pFormFillEnv->GetInteractiveForm()->GetWidget( GetSmartFieldControl(pFormField)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -919,10 +918,10 @@ CJS_Result CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { if (!IsComboBoxOrTextField(pFormField)) return CJS_Result::Failure(JSMessage::kObjectTypeError); - CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); - CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>( - pInterForm->FindFieldInCalculationOrder(pFormField)))); + CPDFSDK_InteractiveForm* pRDForm = m_pFormFillEnv->GetInteractiveForm(); + CPDF_InteractiveForm* pForm = pRDForm->GetInteractiveForm(); + return CJS_Result::Success(pRuntime->NewNumber( + static_cast<int32_t>(pForm->FindFieldInCalculationOrder(pFormField)))); } CJS_Result CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime, @@ -1151,9 +1150,8 @@ CJS_Result CJS_Field::get_display(CJS_Runtime* pRuntime) { if (!pFormField) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(GetSmartFieldControl(pFormField)); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); + CPDFSDK_Widget* pWidget = pForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1344,9 +1342,8 @@ CJS_Result CJS_Field::get_hidden(CJS_Runtime* pRuntime) { if (!pFormField) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(GetSmartFieldControl(pFormField)); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); + CPDFSDK_Widget* pWidget = pForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1416,11 +1413,11 @@ CJS_Result CJS_Field::get_line_width(CJS_Runtime* pRuntime) { if (!pFormControl) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); if (!pFormField->CountControls()) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); + CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormField->GetControl(0)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1518,7 +1515,7 @@ CJS_Result CJS_Field::get_page(CJS_Runtime* pRuntime) { return CJS_Result::Failure(JSMessage::kBadObjectError); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; - m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); + m_pFormFillEnv->GetInteractiveForm()->GetWidgets(pFormField, &widgets); if (widgets.empty()) return CJS_Result::Success(pRuntime->NewNumber(-1)); @@ -1568,13 +1565,12 @@ CJS_Result CJS_Field::set_password(CJS_Runtime* pRuntime, } CJS_Result CJS_Field::get_print(CJS_Runtime* pRuntime) { - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(GetSmartFieldControl(pFormField)); + CPDFSDK_Widget* pWidget = pForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1584,7 +1580,7 @@ CJS_Result CJS_Field::get_print(CJS_Runtime* pRuntime) { CJS_Result CJS_Field::set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1597,7 +1593,7 @@ CJS_Result CJS_Field::set_print(CJS_Runtime* pRuntime, bool bSet = false; for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { if (CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(pFormField->GetControl(i))) { + pForm->GetWidget(pFormField->GetControl(i))) { uint32_t dwFlags = pWidget->GetFlags(); if (pRuntime->ToBoolean(vp)) dwFlags |= ANNOTFLAG_PRINT; @@ -1622,7 +1618,7 @@ CJS_Result CJS_Field::set_print(CJS_Runtime* pRuntime, if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex)) { - if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { + if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { uint32_t dwFlags = pWidget->GetFlags(); if (pRuntime->ToBoolean(vp)) dwFlags |= ANNOTFLAG_PRINT; @@ -1687,9 +1683,8 @@ CJS_Result CJS_Field::get_rect(CJS_Runtime* pRuntime) { if (!pFormField) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - CPDFSDK_Widget* pWidget = - pInterForm->GetWidget(GetSmartFieldControl(pFormField)); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); + CPDFSDK_Widget* pWidget = pForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -2494,10 +2489,10 @@ CJS_Result CJS_Field::setFocus( if (nCount < 1) return CJS_Result::Failure(JSMessage::kBadObjectError); - CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); + CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm(); CPDFSDK_Widget* pWidget = nullptr; if (nCount == 1) { - pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); + pWidget = pForm->GetWidget(pFormField->GetControl(0)); } else { IPDF_Page* pPage = IPDFPageFromFPDFPage(m_pFormFillEnv->GetCurrentPage()); if (!pPage) @@ -2506,7 +2501,7 @@ CJS_Result CJS_Field::setFocus( m_pFormFillEnv->GetPageView(pPage, true)) { for (int32_t i = 0; i < nCount; i++) { if (CPDFSDK_Widget* pTempWidget = - pInterForm->GetWidget(pFormField->GetControl(i))) { + pForm->GetWidget(pFormField->GetControl(i))) { if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { pWidget = pTempWidget; break; diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index fb2df6a716..2e0603c982 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -1584,9 +1584,9 @@ CJS_Result CJS_PublicMethods::AFSimple_Calculate( if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString()) return CJS_Result::Failure(JSMessage::kParamError); - CPDFSDK_InterForm* pReaderInterForm = - pRuntime->GetFormFillEnv()->GetInterForm(); - CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); + CPDFSDK_InteractiveForm* pReaderForm = + pRuntime->GetFormFillEnv()->GetInteractiveForm(); + CPDF_InteractiveForm* pForm = pReaderForm->GetInteractiveForm(); WideString sFunction = pRuntime->ToWideString(params[0]); double dValue = wcscmp(sFunction.c_str(), L"PRD") == 0 ? 1.0 : 0.0; @@ -1598,8 +1598,8 @@ CJS_Result CJS_PublicMethods::AFSimple_Calculate( WideString wsFieldName = pRuntime->ToWideString(pRuntime->GetArrayElement(FieldNameArray, i)); - for (size_t j = 0; j < pInterForm->CountFields(wsFieldName); ++j) { - CPDF_FormField* pFormField = pInterForm->GetField(j, wsFieldName); + for (size_t j = 0; j < pForm->CountFields(wsFieldName); ++j) { + CPDF_FormField* pFormField = pForm->GetField(j, wsFieldName); if (!pFormField) continue; |