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

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 2355083002: Make CPDF_Array not do indirect object creation. (Closed)
Patch Set: Missed two references Created 4 years, 3 months 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/fpdfapi/fpdf_parser/include/cpdf_array.h ('k') | no next file » | 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Datasets 178 // Datasets
179 pContext->UpdateChecksum(pDsfileWrite.get()); 179 pContext->UpdateChecksum(pDsfileWrite.get());
180 pContext->FinishChecksum(); 180 pContext->FinishChecksum();
181 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 181 CPDF_Dictionary* pDataDict = new CPDF_Dictionary;
182 if (iDataSetsIndex != -1) { 182 if (iDataSetsIndex != -1) {
183 if (pDataSetsStream) 183 if (pDataSetsStream)
184 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 184 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
185 } else { 185 } else {
186 CPDF_Stream* pData = new CPDF_Stream; 186 CPDF_Stream* pData = new CPDF_Stream;
187 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 187 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
188 pPDFDocument->AddIndirectObject(pData); 188 uint32_t objnum = pPDFDocument->AddIndirectObject(pData);
189 iLast = pArray->GetCount() - 2; 189 iLast = pArray->GetCount() - 2;
190 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE)); 190 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE));
191 pArray->InsertAt(iLast + 1, pData, pPDFDocument); 191 pArray->InsertAt(iLast + 1, new CPDF_Reference(pPDFDocument, objnum));
192 } 192 }
193 fileList->push_back(std::move(pDsfileWrite)); 193 fileList->push_back(std::move(pDsfileWrite));
194 } 194 }
195 } 195 }
196 // L"form" 196 // L"form"
197 { 197 {
198 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 198 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
199 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), 199 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
200 pContext.get()) && 200 pContext.get()) &&
201 pfileWrite->GetSize() > 0) { 201 pfileWrite->GetSize() > 0) {
202 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 202 CPDF_Dictionary* pDataDict = new CPDF_Dictionary;
203 if (iFormIndex != -1) { 203 if (iFormIndex != -1) {
204 if (pFormStream) 204 if (pFormStream)
205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); 205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
206 } else { 206 } else {
207 CPDF_Stream* pData = new CPDF_Stream; 207 CPDF_Stream* pData = new CPDF_Stream;
208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
209 pPDFDocument->AddIndirectObject(pData); 209 uint32_t objnum = pPDFDocument->AddIndirectObject(pData);
210 iLast = pArray->GetCount() - 2; 210 iLast = pArray->GetCount() - 2;
211 pArray->InsertAt(iLast, new CPDF_String("form", FALSE)); 211 pArray->InsertAt(iLast, new CPDF_String("form", FALSE));
212 pArray->InsertAt(iLast + 1, pData, pPDFDocument); 212 pArray->InsertAt(iLast + 1, new CPDF_Reference(pPDFDocument, objnum));
213 } 213 }
214 fileList->push_back(std::move(pfileWrite)); 214 fileList->push_back(std::move(pfileWrite));
215 } 215 }
216 } 216 }
217 return true; 217 return true;
218 } 218 }
219 219
220 bool SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) { 220 bool SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) {
221 if (!pDocument) 221 if (!pDocument)
222 return false; 222 return false;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 FPDF_DWORD flags) { 308 FPDF_DWORD flags) {
309 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 309 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
310 } 310 }
311 311
312 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 312 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
313 FPDF_FILEWRITE* pFileWrite, 313 FPDF_FILEWRITE* pFileWrite,
314 FPDF_DWORD flags, 314 FPDF_DWORD flags,
315 int fileVersion) { 315 int fileVersion) {
316 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 316 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
317 } 317 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_array.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698