OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |