diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-02-02 16:02:03 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-02-02 16:02:03 -0800 |
commit | ed5d7aa789ec5ef7b440d7e56b71804b41a928e3 (patch) | |
tree | 028bced4e1203313752240a1a3de7fbf998611c3 /core/src/fpdfdoc | |
parent | 23bf560507a8e03968e66480281597be9161abf4 (diff) | |
download | pdfium-ed5d7aa789ec5ef7b440d7e56b71804b41a928e3.tar.xz |
Merge to XFA: Kill CFX_ByteArray in master.
One trivial edit in fx_basic.h
Includes both fixes for build breakage.
Review URL: https://codereview.chromium.org/1653253002 .
(cherry picked from commit 9b0a59d659d8083802385649ba74370d65c41e36)
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1655423002 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formcontrol.cpp | 9 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 22 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 16 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_utils.h | 4 |
5 files changed, 23 insertions, 34 deletions
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index b07fe45ed5..5cfad3f068 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -1175,10 +1175,6 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, return; } } - CFX_ByteArray statusArray; - if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { - SaveCheckedFieldStatus(pField, statusArray); - } pField->SetValue(csWValue); CPDF_FormField::Type eType = pField->GetType(); if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && @@ -1188,7 +1184,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, } if (bNotify && m_pFormNotify) { if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { - m_pFormNotify->AfterCheckedStatusChange(pField, statusArray); + m_pFormNotify->AfterCheckedStatusChange(pField); } else if (iType == FIELDTYPE_LISTBOX) { m_pFormNotify->AfterSelectionChange(pField); } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) { diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index feaff38f16..169e9d73b7 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -17,7 +17,7 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, CFX_FloatRect CPDF_FormControl::GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); } -CFX_ByteString CPDF_FormControl::GetOnStateName() { +CFX_ByteString CPDF_FormControl::GetOnStateName() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CFX_ByteString csOn; @@ -112,14 +112,16 @@ CFX_WideString CPDF_FormControl::GetExportValue() { CFX_WideString csWOn = PDF_DecodeText(csOn); return csWOn; } -FX_BOOL CPDF_FormControl::IsChecked() { + +bool CPDF_FormControl::IsChecked() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CFX_ByteString csOn = GetOnStateName(); CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS"); return csAS == csOn; } -FX_BOOL CPDF_FormControl::IsDefaultChecked() { + +bool CPDF_FormControl::IsDefaultChecked() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV"); @@ -130,6 +132,7 @@ FX_BOOL CPDF_FormControl::IsDefaultChecked() { CFX_ByteString csOn = GetOnStateName(); return (csDV == csOn); } + void CPDF_FormControl::CheckControl(FX_BOOL bChecked) { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 39af0c94c7..31557b490d 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -102,10 +102,6 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { switch (m_Type) { case CPDF_FormField::CheckBox: case CPDF_FormField::RadioButton: { - CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify) { - SaveCheckedFieldStatus(this, statusArray); - } int iCount = CountControls(); if (iCount) { if (PDF_FormField_IsUnison(this)) { @@ -121,7 +117,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { } } if (bNotify && m_pForm->m_pFormNotify) { - m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); + m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); } } break; case CPDF_FormField::ComboBox: { @@ -805,8 +801,8 @@ FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify) { } #endif // PDF_ENABLE_XFA FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, - FX_BOOL bChecked, - FX_BOOL bNotify) { + bool bChecked, + bool bNotify) { ASSERT(GetType() == CheckBox || GetType() == RadioButton); CPDF_FormControl* pControl = GetControl(iControlIndex); if (!pControl) { @@ -815,10 +811,6 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, if (!bChecked && pControl->IsChecked() == bChecked) { return FALSE; } - CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify) { - SaveCheckedFieldStatus(this, statusArray); - } CFX_WideString csWExport = pControl->GetExportValue(); CFX_ByteString csBExport = PDF_EncodeText(csWExport); int iCount = CountControls(); @@ -864,7 +856,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, m_pDict->SetAtName("V", csIndex); } if (bNotify && m_pForm->m_pFormNotify) { - m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); + m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); } m_pForm->m_bUpdated = TRUE; return TRUE; @@ -892,10 +884,6 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify) { ASSERT(GetType() == CheckBox || GetType() == RadioButton); - CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify) { - SaveCheckedFieldStatus(this, statusArray); - } int iCount = CountControls(); for (int i = 0; i < iCount; i++) { CPDF_FormControl* pControl = GetControl(i); @@ -914,7 +902,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value, } } if (bNotify && m_pForm->m_pFormNotify) { - m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); + m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); } m_pForm->m_bUpdated = TRUE; return TRUE; diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 7db2887834..a2c0454bc9 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -678,17 +678,17 @@ FX_BOOL CPDF_IconFit::GetFittingBounds() { } return m_pDict->GetBooleanBy("FB"); } -void SaveCheckedFieldStatus(CPDF_FormField* pField, - CFX_ByteArray& statusArray) { + +std::vector<bool> SaveCheckedFieldStatus(CPDF_FormField* pField) { + std::vector<bool> result; int iCount = pField->CountControls(); - for (int i = 0; i < iCount; i++) { - CPDF_FormControl* pControl = pField->GetControl(i); - if (!pControl) { - continue; - } - statusArray.Add(pControl->IsChecked() ? 1 : 0); + for (int i = 0; i < iCount; ++i) { + if (CPDF_FormControl* pControl = pField->GetControl(i)) + result.push_back(pControl->IsChecked()); } + return result; } + CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel) { diff --git a/core/src/fpdfdoc/doc_utils.h b/core/src/fpdfdoc/doc_utils.h index 4a6652f9c6..58eee84380 100644 --- a/core/src/fpdfdoc/doc_utils.h +++ b/core/src/fpdfdoc/doc_utils.h @@ -7,6 +7,8 @@ #ifndef CORE_SRC_FPDFDOC_DOC_UTILS_H_ #define CORE_SRC_FPDFDOC_DOC_UTILS_H_ +#include <vector> + CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict); void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument); FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict); @@ -54,7 +56,7 @@ CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, void SetDefaultInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont); -void SaveCheckedFieldStatus(CPDF_FormField* pField, CFX_ByteArray& statusArray); +std::vector<bool> SaveCheckedFieldStatus(CPDF_FormField* pField); FX_BOOL NeedPDFEncodeForFieldFullName(const CFX_WideString& csFieldName); FX_BOOL NeedPDFEncodeForFieldTree(CPDF_Dictionary* pFieldDict, int nLevel = 0); void EncodeFieldName(const CFX_WideString& csName, CFX_ByteString& csT); |