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

Side by Side Diff: core/src/fpdfdoc/doc_form.cpp

Issue 1540693002: Get rid of a few CPDF_Object Create() methods and just use new instead. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 5 years 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/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formfield.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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "core/include/fpdfdoc/fpdf_doc.h" 7 #include "core/include/fpdfdoc/fpdf_doc.h"
8 #include "doc_utils.h" 8 #include "doc_utils.h"
9 9
10 const int nMaxRecursion = 32; 10 const int nMaxRecursion = 32;
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 if (bSimpleFileSpec) { 1041 if (bSimpleFileSpec) {
1042 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); 1042 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path);
1043 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath)); 1043 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath));
1044 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath)); 1044 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath));
1045 } else { 1045 } else {
1046 CPDF_FileSpec filespec; 1046 CPDF_FileSpec filespec;
1047 filespec.SetFileName(pdf_path); 1047 filespec.SetFileName(pdf_path);
1048 pMainDict->SetAt("F", static_cast<CPDF_Object*>(filespec)); 1048 pMainDict->SetAt("F", static_cast<CPDF_Object*>(filespec));
1049 } 1049 }
1050 } 1050 }
1051 CPDF_Array* pFields = CPDF_Array::Create(); 1051 CPDF_Array* pFields = new CPDF_Array;
1052 if (!pFields) {
1053 return NULL;
1054 }
1055 pMainDict->SetAt("Fields", pFields); 1052 pMainDict->SetAt("Fields", pFields);
1056 int nCount = m_pFieldTree->m_Root.CountFields(); 1053 int nCount = m_pFieldTree->m_Root.CountFields();
1057 for (int i = 0; i < nCount; i++) { 1054 for (int i = 0; i < nCount; i++) {
1058 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1055 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1059 if (!pField || pField->GetType() == CPDF_FormField::PushButton) { 1056 if (!pField || pField->GetType() == CPDF_FormField::PushButton) {
1060 continue; 1057 continue;
1061 } 1058 }
1062 FX_DWORD dwFlags = pField->GetFieldFlags(); 1059 FX_DWORD dwFlags = pField->GetFieldFlags();
1063 if (dwFlags & 0x04) 1060 if (dwFlags & 0x04)
1064 continue; 1061 continue;
1065 1062
1066 auto it = std::find(fields.begin(), fields.end(), pField); 1063 auto it = std::find(fields.begin(), fields.end(), pField);
1067 if (bIncludeOrExclude == (it != fields.end())) { 1064 if (bIncludeOrExclude == (it != fields.end())) {
1068 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty()) 1065 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty())
1069 continue; 1066 continue;
1070 1067
1071 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); 1068 CFX_WideString fullname = GetFullName(pField->GetFieldDict());
1072 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); 1069 CPDF_Dictionary* pFieldDict = new CPDF_Dictionary;
1073 if (!pFieldDict) 1070 pFieldDict->SetAt("T", new CPDF_String(fullname));
1074 return nullptr;
1075
1076 CPDF_String* pString = CPDF_String::Create(fullname);
1077 if (!pString) {
1078 pFieldDict->Release();
1079 return nullptr;
1080 }
1081 pFieldDict->SetAt("T", pString);
1082 if (pField->GetType() == CPDF_FormField::CheckBox || 1071 if (pField->GetType() == CPDF_FormField::CheckBox ||
1083 pField->GetType() == CPDF_FormField::RadioButton) { 1072 pField->GetType() == CPDF_FormField::RadioButton) {
1084 CFX_WideString csExport = pField->GetCheckValue(FALSE); 1073 CFX_WideString csExport = pField->GetCheckValue(FALSE);
1085 CFX_ByteString csBExport = PDF_EncodeText(csExport); 1074 CFX_ByteString csBExport = PDF_EncodeText(csExport);
1086 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); 1075 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
1087 if (pOpt) 1076 if (pOpt)
1088 pFieldDict->SetAtString("V", csBExport); 1077 pFieldDict->SetAtString("V", csBExport);
1089 else 1078 else
1090 pFieldDict->SetAtName("V", csBExport); 1079 pFieldDict->SetAtName("V", csBExport);
1091 } else { 1080 } else {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 FDF_ImportField(pField, L"", bNotify); 1215 FDF_ImportField(pField, L"", bNotify);
1227 } 1216 }
1228 if (bNotify && m_pFormNotify) { 1217 if (bNotify && m_pFormNotify) {
1229 m_pFormNotify->AfterFormImportData(this); 1218 m_pFormNotify->AfterFormImportData(this);
1230 } 1219 }
1231 return TRUE; 1220 return TRUE;
1232 } 1221 }
1233 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { 1222 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) {
1234 m_pFormNotify = (CPDF_FormNotify*)pNotify; 1223 m_pFormNotify = (CPDF_FormNotify*)pNotify;
1235 } 1224 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formfield.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698