diff options
author | tsepez <tsepez@chromium.org> | 2016-11-16 12:26:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-16 12:26:06 -0800 |
commit | 8a3aa459fc5284f51bcd7e98e95bf6214f47bb67 (patch) | |
tree | 13fb383936d679aded19054f4e7a0387dd52de76 /core/fpdfdoc/cpdf_formfield.cpp | |
parent | 14a60c50b10de1d9e4edd3629ea210a816940a75 (diff) | |
download | pdfium-8a3aa459fc5284f51bcd7e98e95bf6214f47bb67.tar.xz |
Make CPDF_Array take unique_ptrs
BUG=
Review-Url: https://codereview.chromium.org/2498223005
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 4999f2d6b8..3a2213f1ae 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -555,7 +555,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); - pArray->AddString(PDF_EncodeText(opt_value)); + pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } m_pDict->SetFor("V", pArray); @@ -563,7 +563,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { } else { m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; - pI->AddInteger(index); + pI->AddNew<CPDF_Number>(index); m_pDict->SetFor("I", pI); } } else { @@ -579,7 +579,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); - pArray->AddString(PDF_EncodeText(opt_value)); + pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } if (pArray->GetCount() > 0) @@ -684,11 +684,10 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, int iCount = pdfium::base::checked_cast<int>(pOpt->GetCount()); if (index >= iCount) { - pOpt->AddString(csStr); + pOpt->AddNew<CPDF_String>(csStr, false); index = iCount; } else { - CPDF_String* pString = new CPDF_String(csStr, false); - pOpt->InsertAt(index, pString); + pOpt->InsertNewAt<CPDF_String>(index, csStr, false); } if (bNotify) @@ -836,7 +835,7 @@ bool CPDF_FormField::IsOptionSelected(int iOptIndex) const { if (!pArray) return false; - for (CPDF_Object* pObj : *pArray) { + for (const auto& pObj : *pArray) { if (pObj->GetInteger() == iOptIndex) return true; } @@ -879,14 +878,14 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) { if (!NotifyListOrComboBoxBeforeChange(csValue)) return false; } - pArray->InsertAt(i, new CPDF_Number(iOptIndex)); + pArray->InsertNewAt<CPDF_Number>(i, iOptIndex); bReturn = true; break; } } if (!bReturn) { if (bSelected) - pArray->AddInteger(iOptIndex); + pArray->AddNew<CPDF_Number>(iOptIndex); if (pArray->IsEmpty()) m_pDict->RemoveFor("I"); |