Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: core/fpdfdoc/cpdf_formfield.cpp

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_dest_unittest.cpp ('k') | core/fpdfdoc/cpdf_interform.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_formfield.cpp
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 4999f2d6b861fb5b4d08508e229f7e9efdf2795d..3a2213f1aee4786647660cdcedbf3fa0cb27e81e 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");
« no previous file with comments | « core/fpdfdoc/cpdf_dest_unittest.cpp ('k') | core/fpdfdoc/cpdf_interform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698