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