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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 pDsfileWrite->GetSize() > 0) { | 173 pDsfileWrite->GetSize() > 0) { |
174 // Datasets | 174 // Datasets |
175 pChecksum->UpdateChecksum(pDsfileWrite.get()); | 175 pChecksum->UpdateChecksum(pDsfileWrite.get()); |
176 pChecksum->FinishChecksum(); | 176 pChecksum->FinishChecksum(); |
177 CPDF_Dictionary* pDataDict = | 177 CPDF_Dictionary* pDataDict = |
178 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); | 178 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); |
179 if (iDataSetsIndex != -1) { | 179 if (iDataSetsIndex != -1) { |
180 if (pDataSetsStream) | 180 if (pDataSetsStream) |
181 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); | 181 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); |
182 } else { | 182 } else { |
183 CPDF_Stream* pData = new CPDF_Stream; | 183 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); |
184 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); | 184 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); |
185 iLast = pArray->GetCount() - 2; | 185 iLast = pArray->GetCount() - 2; |
186 pArray->InsertAt(iLast, new CPDF_String("datasets", false)); | 186 pArray->InsertAt(iLast, new CPDF_String("datasets", false)); |
187 pArray->InsertAt( | 187 pArray->InsertAt(iLast + 1, |
188 iLast + 1, | 188 new CPDF_Reference(pPDFDocument, pData->GetObjNum())); |
189 new CPDF_Reference(pPDFDocument, | |
190 pPDFDocument->AddIndirectObject(pData))); | |
191 } | 189 } |
192 fileList->push_back(std::move(pDsfileWrite)); | 190 fileList->push_back(std::move(pDsfileWrite)); |
193 } | 191 } |
194 } | 192 } |
195 // L"form" | 193 // L"form" |
196 { | 194 { |
197 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); | 195 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); |
198 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), | 196 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), |
199 pChecksum.get()) && | 197 pChecksum.get()) && |
200 pfileWrite->GetSize() > 0) { | 198 pfileWrite->GetSize() > 0) { |
201 CPDF_Dictionary* pDataDict = | 199 CPDF_Dictionary* pDataDict = |
202 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); | 200 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); |
203 if (iFormIndex != -1) { | 201 if (iFormIndex != -1) { |
204 if (pFormStream) | 202 if (pFormStream) |
205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); | 203 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); |
206 } else { | 204 } else { |
207 CPDF_Stream* pData = new CPDF_Stream; | 205 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); |
208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); | 206 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); |
209 iLast = pArray->GetCount() - 2; | 207 iLast = pArray->GetCount() - 2; |
210 pArray->InsertAt(iLast, new CPDF_String("form", false)); | 208 pArray->InsertAt(iLast, new CPDF_String("form", false)); |
211 pArray->InsertAt( | 209 pArray->InsertAt(iLast + 1, |
212 iLast + 1, | 210 new CPDF_Reference(pPDFDocument, pData->GetObjNum())); |
213 new CPDF_Reference(pPDFDocument, | |
214 pPDFDocument->AddIndirectObject(pData))); | |
215 } | 211 } |
216 fileList->push_back(std::move(pfileWrite)); | 212 fileList->push_back(std::move(pfileWrite)); |
217 } | 213 } |
218 } | 214 } |
219 return true; | 215 return true; |
220 } | 216 } |
221 | 217 |
222 bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { | 218 bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { |
223 if (!pContext) | 219 if (!pContext) |
224 return false; | 220 return false; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 FPDF_DWORD flags) { | 306 FPDF_DWORD flags) { |
311 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); | 307 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); |
312 } | 308 } |
313 | 309 |
314 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, | 310 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, |
315 FPDF_FILEWRITE* pFileWrite, | 311 FPDF_FILEWRITE* pFileWrite, |
316 FPDF_DWORD flags, | 312 FPDF_DWORD flags, |
317 int fileVersion) { | 313 int fileVersion) { |
318 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); | 314 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); |
319 } | 315 } |
OLD | NEW |