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

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: more 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
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 // L"datasets" 172 // L"datasets"
173 { 173 {
174 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream()); 174 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream());
175 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, 175 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets,
176 pDsfileWrite.get(), nullptr) && 176 pDsfileWrite.get(), nullptr) &&
177 pDsfileWrite->GetSize() > 0) { 177 pDsfileWrite->GetSize() > 0) {
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 =
182 new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
182 if (iDataSetsIndex != -1) { 183 if (iDataSetsIndex != -1) {
183 if (pDataSetsStream) 184 if (pDataSetsStream)
184 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 185 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
185 } else { 186 } else {
186 CPDF_Stream* pData = new CPDF_Stream(nullptr, 0, nullptr); 187 CPDF_Stream* pData = new CPDF_Stream(nullptr, 0, nullptr);
187 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 188 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
188 pPDFDocument->AddIndirectObject(pData); 189 pPDFDocument->AddIndirectObject(pData);
189 iLast = pArray->GetCount() - 2; 190 iLast = pArray->GetCount() - 2;
190 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE)); 191 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE));
191 pArray->InsertAt(iLast + 1, pData, pPDFDocument); 192 pArray->InsertAt(iLast + 1, pData, pPDFDocument);
192 } 193 }
193 fileList->push_back(std::move(pDsfileWrite)); 194 fileList->push_back(std::move(pDsfileWrite));
194 } 195 }
195 } 196 }
196 // L"form" 197 // L"form"
197 { 198 {
198 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 199 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
199 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), 200 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
200 pContext.get()) && 201 pContext.get()) &&
201 pfileWrite->GetSize() > 0) { 202 pfileWrite->GetSize() > 0) {
202 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 203 CPDF_Dictionary* pDataDict =
204 new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
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(nullptr, 0, nullptr); 209 CPDF_Stream* pData = new CPDF_Stream(nullptr, 0, nullptr);
208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 210 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
209 pPDFDocument->AddIndirectObject(pData); 211 pPDFDocument->AddIndirectObject(pData);
210 iLast = pArray->GetCount() - 2; 212 iLast = pArray->GetCount() - 2;
211 pArray->InsertAt(iLast, new CPDF_String("form", FALSE)); 213 pArray->InsertAt(iLast, new CPDF_String("form", FALSE));
212 pArray->InsertAt(iLast + 1, pData, pPDFDocument); 214 pArray->InsertAt(iLast + 1, pData, pPDFDocument);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 FPDF_DWORD flags) { 310 FPDF_DWORD flags) {
309 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 311 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
310 } 312 }
311 313
312 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 314 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
313 FPDF_FILEWRITE* pFileWrite, 315 FPDF_FILEWRITE* pFileWrite,
314 FPDF_DWORD flags, 316 FPDF_DWORD flags,
315 int fileVersion) { 317 int fileVersion) {
316 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 318 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
317 } 319 }
OLDNEW
« core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h ('K') | « fpdfsdk/fpdfppo.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698