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

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile Created 4 years, 2 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 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; 187 CPDF_Stream* pData = new CPDF_Stream;
187 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 188 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
188 iLast = pArray->GetCount() - 2; 189 iLast = pArray->GetCount() - 2;
189 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE)); 190 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE));
190 pArray->InsertAt( 191 pArray->InsertAt(
191 iLast + 1, 192 iLast + 1,
192 new CPDF_Reference(pPDFDocument, 193 new CPDF_Reference(pPDFDocument,
193 pPDFDocument->AddIndirectObject(pData))); 194 pPDFDocument->AddIndirectObject(pData)));
194 } 195 }
195 fileList->push_back(std::move(pDsfileWrite)); 196 fileList->push_back(std::move(pDsfileWrite));
196 } 197 }
197 } 198 }
198 // L"form" 199 // L"form"
199 { 200 {
200 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 201 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
201 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), 202 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(),
202 pContext.get()) && 203 pContext.get()) &&
203 pfileWrite->GetSize() > 0) { 204 pfileWrite->GetSize() > 0) {
204 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 205 CPDF_Dictionary* pDataDict =
206 new CPDF_Dictionary(pPDFDocument->GetByteStringPool());
205 if (iFormIndex != -1) { 207 if (iFormIndex != -1) {
206 if (pFormStream) 208 if (pFormStream)
207 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); 209 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
208 } else { 210 } else {
209 CPDF_Stream* pData = new CPDF_Stream; 211 CPDF_Stream* pData = new CPDF_Stream;
210 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 212 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
211 iLast = pArray->GetCount() - 2; 213 iLast = pArray->GetCount() - 2;
212 pArray->InsertAt(iLast, new CPDF_String("form", FALSE)); 214 pArray->InsertAt(iLast, new CPDF_String("form", FALSE));
213 pArray->InsertAt( 215 pArray->InsertAt(
214 iLast + 1, 216 iLast + 1,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 FPDF_DWORD flags) { 314 FPDF_DWORD flags) {
313 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 315 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
314 } 316 }
315 317
316 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 318 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
317 FPDF_FILEWRITE* pFileWrite, 319 FPDF_FILEWRITE* pFileWrite,
318 FPDF_DWORD flags, 320 FPDF_DWORD flags,
319 int fileVersion) { 321 int fileVersion) {
320 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 322 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
321 } 323 }
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