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

Side by Side Diff: fpdfsdk/fpdfsave.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 unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfppo.cpp ('k') | testing/libfuzzer/pdf_hint_table_fuzzer.cc » ('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 "public/fpdf_save.h" 7 #include "public/fpdf_save.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 pChecksum->FinishChecksum(); 176 pChecksum->FinishChecksum();
177 CPDF_Dictionary* pDataDict = 177 CPDF_Dictionary* pDataDict =
178 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); 178 new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
179 if (iDataSetsIndex != -1) { 179 if (iDataSetsIndex != -1) {
180 if (pDataSetsStream) 180 if (pDataSetsStream)
181 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 181 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
182 } else { 182 } else {
183 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); 183 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>();
184 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 184 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
185 iLast = pArray->GetCount() - 2; 185 iLast = pArray->GetCount() - 2;
186 pArray->InsertAt(iLast, new CPDF_String("datasets", false)); 186 pArray->InsertNewAt<CPDF_String>(iLast, "datasets", false);
187 pArray->InsertAt(iLast + 1, 187 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,
188 new CPDF_Reference(pPDFDocument, pData->GetObjNum())); 188 pData->GetObjNum());
189 } 189 }
190 fileList->push_back(std::move(pDsfileWrite)); 190 fileList->push_back(std::move(pDsfileWrite));
191 } 191 }
192 } 192 }
193 // L"form" 193 // L"form"
194 { 194 {
195 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 195 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
196 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), 196 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
197 pChecksum.get()) && 197 pChecksum.get()) &&
198 pfileWrite->GetSize() > 0) { 198 pfileWrite->GetSize() > 0) {
199 CPDF_Dictionary* pDataDict = 199 CPDF_Dictionary* pDataDict =
200 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); 200 new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
201 if (iFormIndex != -1) { 201 if (iFormIndex != -1) {
202 if (pFormStream) 202 if (pFormStream)
203 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); 203 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
204 } else { 204 } else {
205 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); 205 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>();
206 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 206 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
207 iLast = pArray->GetCount() - 2; 207 iLast = pArray->GetCount() - 2;
208 pArray->InsertAt(iLast, new CPDF_String("form", false)); 208 pArray->InsertNewAt<CPDF_String>(iLast, "form", false);
209 pArray->InsertAt(iLast + 1, 209 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,
210 new CPDF_Reference(pPDFDocument, pData->GetObjNum())); 210 pData->GetObjNum());
211 } 211 }
212 fileList->push_back(std::move(pfileWrite)); 212 fileList->push_back(std::move(pfileWrite));
213 } 213 }
214 } 214 }
215 return true; 215 return true;
216 } 216 }
217 217
218 bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { 218 bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) {
219 if (!pContext) 219 if (!pContext)
220 return false; 220 return false;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 FPDF_DWORD flags) { 306 FPDF_DWORD flags) {
307 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); 307 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0);
308 } 308 }
309 309
310 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 310 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
311 FPDF_FILEWRITE* pFileWrite, 311 FPDF_FILEWRITE* pFileWrite,
312 FPDF_DWORD flags, 312 FPDF_DWORD flags,
313 int fileVersion) { 313 int fileVersion) {
314 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); 314 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion);
315 } 315 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfppo.cpp ('k') | testing/libfuzzer/pdf_hint_table_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698