diff options
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_annotlist.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formcontrol.h | 8 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 3 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.h | 10 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interactiveform.cpp | 108 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interactiveform.h | 12 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_fontmap.cpp | 3 | ||||
-rw-r--r-- | core/fpdfdoc/ipdf_formnotify.h | 4 |
8 files changed, 80 insertions, 70 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_ |