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

Side by Side Diff: core/fpdfdoc/cpdf_interform.cpp

Issue 2484033002: Return unique_ptr from CPDF_Object::Clone(). (Closed)
Patch Set: std::move() it 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 unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_formfield.cpp ('k') | core/fpdfdoc/cpvt_generateap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "core/fpdfapi/font/cpdf_font.h" 9 #include "core/fpdfapi/font/cpdf_font.h"
10 #include "core/fpdfapi/font/cpdf_fontencoding.h" 10 #include "core/fpdfapi/font/cpdf_fontencoding.h"
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 pFieldDict->GetStringFor("Subtype") == "Widget") { 1098 pFieldDict->GetStringFor("Subtype") == "Widget") {
1099 pParent = pFieldDict->GetDictFor("Parent"); 1099 pParent = pFieldDict->GetDictFor("Parent");
1100 if (!pParent) 1100 if (!pParent)
1101 pParent = pFieldDict; 1101 pParent = pFieldDict;
1102 } 1102 }
1103 1103
1104 if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) { 1104 if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) {
1105 if (pFieldDict->KeyExist("FT")) { 1105 if (pFieldDict->KeyExist("FT")) {
1106 CPDF_Object* pFTValue = pFieldDict->GetDirectObjectFor("FT"); 1106 CPDF_Object* pFTValue = pFieldDict->GetDirectObjectFor("FT");
1107 if (pFTValue) 1107 if (pFTValue)
1108 pParent->SetFor("FT", pFTValue->Clone()); 1108 pParent->SetFor("FT", pFTValue->Clone().release());
1109 } 1109 }
1110 1110
1111 if (pFieldDict->KeyExist("Ff")) { 1111 if (pFieldDict->KeyExist("Ff")) {
1112 CPDF_Object* pFfValue = pFieldDict->GetDirectObjectFor("Ff"); 1112 CPDF_Object* pFfValue = pFieldDict->GetDirectObjectFor("Ff");
1113 if (pFfValue) 1113 if (pFfValue)
1114 pParent->SetFor("Ff", pFfValue->Clone()); 1114 pParent->SetFor("Ff", pFfValue->Clone().release());
1115 } 1115 }
1116 } 1116 }
1117 1117
1118 pField = new CPDF_FormField(this, pParent); 1118 pField = new CPDF_FormField(this, pParent);
1119 CPDF_Object* pTObj = pDict->GetObjectFor("T"); 1119 CPDF_Object* pTObj = pDict->GetObjectFor("T");
1120 if (ToReference(pTObj)) { 1120 if (ToReference(pTObj)) {
1121 CPDF_Object* pClone = pTObj->CloneDirectObject(); 1121 std::unique_ptr<CPDF_Object> pClone = pTObj->CloneDirectObject();
1122 if (pClone) 1122 if (pClone)
1123 pDict->SetFor("T", pClone); 1123 pDict->SetFor("T", pClone.release());
1124 else 1124 else
1125 pDict->SetNameFor("T", ""); 1125 pDict->SetNameFor("T", "");
1126 } 1126 }
1127 m_pFieldTree->SetField(csWName, pField); 1127 m_pFieldTree->SetField(csWName, pField);
1128 } 1128 }
1129 1129
1130 CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids"); 1130 CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids");
1131 if (pKids) { 1131 if (pKids) {
1132 for (size_t i = 0; i < pKids->GetCount(); i++) { 1132 for (size_t i = 0; i < pKids->GetCount(); i++) {
1133 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 1133 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 CFX_WideString csExport = pField->GetCheckValue(false); 1244 CFX_WideString csExport = pField->GetCheckValue(false);
1245 CFX_ByteString csBExport = PDF_EncodeText(csExport); 1245 CFX_ByteString csBExport = PDF_EncodeText(csExport);
1246 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); 1246 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
1247 if (pOpt) 1247 if (pOpt)
1248 pFieldDict->SetStringFor("V", csBExport); 1248 pFieldDict->SetStringFor("V", csBExport);
1249 else 1249 else
1250 pFieldDict->SetNameFor("V", csBExport); 1250 pFieldDict->SetNameFor("V", csBExport);
1251 } else { 1251 } else {
1252 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); 1252 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
1253 if (pV) 1253 if (pV)
1254 pFieldDict->SetFor("V", pV->CloneDirectObject()); 1254 pFieldDict->SetFor("V", pV->CloneDirectObject().release());
1255 } 1255 }
1256 pFields->Add(pFieldDict); 1256 pFields->Add(pFieldDict);
1257 } 1257 }
1258 } 1258 }
1259 return pDoc; 1259 return pDoc;
1260 } 1260 }
1261 1261
1262 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, 1262 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
1263 const CFX_WideString& parent_name, 1263 const CFX_WideString& parent_name,
1264 bool bNotify, 1264 bool bNotify,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 1297
1298 if (iRet < 0) 1298 if (iRet < 0)
1299 return; 1299 return;
1300 } 1300 }
1301 1301
1302 pField->SetValue(csWValue); 1302 pField->SetValue(csWValue);
1303 CPDF_FormField::Type eType = pField->GetType(); 1303 CPDF_FormField::Type eType = pField->GetType();
1304 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && 1304 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) &&
1305 pFieldDict->KeyExist("Opt")) { 1305 pFieldDict->KeyExist("Opt")) {
1306 pField->m_pDict->SetFor( 1306 pField->m_pDict->SetFor(
1307 "Opt", pFieldDict->GetDirectObjectFor("Opt")->CloneDirectObject()); 1307 "Opt",
1308 pFieldDict->GetDirectObjectFor("Opt")->CloneDirectObject().release());
1308 } 1309 }
1309 1310
1310 if (bNotify && m_pFormNotify) { 1311 if (bNotify && m_pFormNotify) {
1311 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) 1312 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON)
1312 m_pFormNotify->AfterCheckedStatusChange(pField); 1313 m_pFormNotify->AfterCheckedStatusChange(pField);
1313 else if (iType == FIELDTYPE_LISTBOX) 1314 else if (iType == FIELDTYPE_LISTBOX)
1314 m_pFormNotify->AfterSelectionChange(pField); 1315 m_pFormNotify->AfterSelectionChange(pField);
1315 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) 1316 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
1316 m_pFormNotify->AfterValueChange(pField); 1317 m_pFormNotify->AfterValueChange(pField);
1317 } 1318 }
1318 } 1319 }
1319 1320
1320 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1321 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1321 m_pFormNotify = pNotify; 1322 m_pFormNotify = pNotify;
1322 } 1323 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_formfield.cpp ('k') | core/fpdfdoc/cpvt_generateap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698