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