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

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 2361713002: Remove some objnum locals with AddIndirectObject (Closed)
Patch Set: Same treatment for arrays 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 | « fpdfsdk/fpdfppo.cpp ('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 uint32_t objnum = pPDFDocument->AddIndirectObject(pData);
189 iLast = pArray->GetCount() - 2; 188 iLast = pArray->GetCount() - 2;
190 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE)); 189 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE));
191 pArray->InsertAt(iLast + 1, new CPDF_Reference(pPDFDocument, objnum)); 190 pArray->InsertAt(
191 iLast + 1,
192 new CPDF_Reference(pPDFDocument,
193 pPDFDocument->AddIndirectObject(pData)));
192 } 194 }
193 fileList->push_back(std::move(pDsfileWrite)); 195 fileList->push_back(std::move(pDsfileWrite));
194 } 196 }
195 } 197 }
196 // L"form" 198 // L"form"
197 { 199 {
198 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 200 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
199 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), 201 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
200 pContext.get()) && 202 pContext.get()) &&
201 pfileWrite->GetSize() > 0) { 203 pfileWrite->GetSize() > 0) {
202 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 204 CPDF_Dictionary* pDataDict = new CPDF_Dictionary;
203 if (iFormIndex != -1) { 205 if (iFormIndex != -1) {
204 if (pFormStream) 206 if (pFormStream)
205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); 207 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
206 } else { 208 } else {
207 CPDF_Stream* pData = new CPDF_Stream; 209 CPDF_Stream* pData = new CPDF_Stream;
208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 210 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
209 uint32_t objnum = pPDFDocument->AddIndirectObject(pData);
210 iLast = pArray->GetCount() - 2; 211 iLast = pArray->GetCount() - 2;
211 pArray->InsertAt(iLast, new CPDF_String("form", FALSE)); 212 pArray->InsertAt(iLast, new CPDF_String("form", FALSE));
212 pArray->InsertAt(iLast + 1, new CPDF_Reference(pPDFDocument, objnum)); 213 pArray->InsertAt(
214 iLast + 1,
215 new CPDF_Reference(pPDFDocument,
216 pPDFDocument->AddIndirectObject(pData)));
213 } 217 }
214 fileList->push_back(std::move(pfileWrite)); 218 fileList->push_back(std::move(pfileWrite));
215 } 219 }
216 } 220 }
217 return true; 221 return true;
218 } 222 }
219 223
220 bool SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) { 224 bool SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) {
221 if (!pDocument) 225 if (!pDocument)
222 return false; 226 return false;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 FPDF_DWORD flags) { 312 FPDF_DWORD flags) {
309 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 313 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
310 } 314 }
311 315
312 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 316 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
313 FPDF_FILEWRITE* pFileWrite, 317 FPDF_FILEWRITE* pFileWrite,
314 FPDF_DWORD flags, 318 FPDF_DWORD flags,
315 int fileVersion) { 319 int fileVersion) {
316 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 320 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
317 } 321 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfppo.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698