diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 16 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.h | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 12 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.h | 5 |
4 files changed, 19 insertions, 18 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index b344327adc..b4aa90e2be 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -31,10 +31,6 @@ const int kFormListMultiSelect = 0x100; const int kFormComboEdit = 0x100; -const int kFormFieldReadOnly = 0x01; -const int kFormFieldRequired = 0x02; -const int kFormFieldNoExport = 0x04; - const int kFormRadioNoToggleOff = 0x100; const int kFormRadioUnison = 0x200; @@ -108,12 +104,12 @@ void CPDF_FormField::SyncFieldFlags() { ? FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger() : 0; m_Flags = 0; - if (flags & 1) - m_Flags |= kFormFieldReadOnly; - if (flags & 2) - m_Flags |= kFormFieldRequired; - if (flags & 4) - m_Flags |= kFormFieldNoExport; + if (flags & FORMFLAG_READONLY) + m_Flags |= FORMFLAG_READONLY; + if (flags & FORMFLAG_REQUIRED) + m_Flags |= FORMFLAG_REQUIRED; + if (flags & FORMFLAG_NOEXPORT) + m_Flags |= FORMFLAG_NOEXPORT; if (type_name == "Btn") { if (flags & 0x8000) { diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index 9a1ddc4599..42608b1122 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -25,6 +25,10 @@ #define FIELDTYPE_TEXTFIELD 6 #define FIELDTYPE_SIGNATURE 7 +#define FORMFLAG_READONLY 0x01 +#define FORMFLAG_REQUIRED 0x02 +#define FORMFLAG_NOEXPORT 0x04 + class CPDF_Dictionary; class CPDF_Font; class CPDF_FormControl; diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 6cffea6222..127e542227 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -1157,7 +1157,7 @@ CPDF_FormControl* CPDF_InterForm::AddControl(CPDF_FormField* pField, return pControl; } -CPDF_FormField* CPDF_InterForm::CheckRequiredFields( +bool CPDF_InterForm::CheckRequiredFields( const std::vector<CPDF_FormField*>* fields, bool bIncludeOrExclude) const { size_t nCount = m_pFieldTree->m_Root.CountFields(); @@ -1173,7 +1173,7 @@ CPDF_FormField* CPDF_InterForm::CheckRequiredFields( } uint32_t dwFlags = pField->GetFieldFlags(); // TODO(thestig): Look up these magic numbers and add constants for them. - if (dwFlags & 0x04) + if (dwFlags & FORMFLAG_NOEXPORT) continue; bool bFind = true; @@ -1181,11 +1181,13 @@ CPDF_FormField* CPDF_InterForm::CheckRequiredFields( bFind = pdfium::ContainsValue(*fields, pField); if (bIncludeOrExclude == bFind) { CPDF_Dictionary* pFieldDict = pField->m_pDict; - if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringFor("V").IsEmpty()) - return pField; + if ((dwFlags & FORMFLAG_REQUIRED) != 0 && + pFieldDict->GetStringFor("V").IsEmpty()) { + return false; + } } } - return nullptr; + return true; } std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF( diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h index b846973435..a42c4cef84 100644 --- a/core/fpdfdoc/cpdf_interform.h +++ b/core/fpdfdoc/cpdf_interform.h @@ -69,9 +69,8 @@ class CPDF_InterForm { CPDF_DefaultAppearance GetDefaultAppearance() const; int GetFormAlignment() const; - CPDF_FormField* CheckRequiredFields( - const std::vector<CPDF_FormField*>* fields, - bool bIncludeOrExclude) const; + bool CheckRequiredFields(const std::vector<CPDF_FormField*>* fields, + bool bIncludeOrExclude) const; std::unique_ptr<CFDF_Document> ExportToFDF(const CFX_WideStringC& pdf_path, bool bSimpleFileSpec) const; |