| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = new 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( |
| 188 iLast + 1, | 188 iLast + 1, |
| 189 new CPDF_Reference(pPDFDocument, | 189 new CPDF_Reference(pPDFDocument, |
| 190 pPDFDocument->AddIndirectObject(pData))); | 190 pPDFDocument->AddIndirectObject(pData))); |
| 191 } | 191 } |
| 192 fileList->push_back(std::move(pDsfileWrite)); | 192 fileList->push_back(std::move(pDsfileWrite)); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 // L"form" | 195 // L"form" |
| 196 { | 196 { |
| 197 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); | 197 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); |
| 198 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), | 198 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), |
| 199 pChecksum.get()) && | 199 pChecksum.get()) && |
| 200 pfileWrite->GetSize() > 0) { | 200 pfileWrite->GetSize() > 0) { |
| 201 CPDF_Dictionary* pDataDict = | 201 CPDF_Dictionary* pDataDict = |
| 202 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); | 202 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); |
| 203 if (iFormIndex != -1) { | 203 if (iFormIndex != -1) { |
| 204 if (pFormStream) | 204 if (pFormStream) |
| 205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); | 205 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); |
| 206 } else { | 206 } else { |
| 207 CPDF_Stream* pData = new CPDF_Stream; | 207 CPDF_Stream* pData = new CPDF_Stream; |
| 208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); | 208 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); |
| 209 iLast = pArray->GetCount() - 2; | 209 iLast = pArray->GetCount() - 2; |
| 210 pArray->InsertAt(iLast, new CPDF_String("form", FALSE)); | 210 pArray->InsertAt(iLast, new CPDF_String("form", false)); |
| 211 pArray->InsertAt( | 211 pArray->InsertAt( |
| 212 iLast + 1, | 212 iLast + 1, |
| 213 new CPDF_Reference(pPDFDocument, | 213 new CPDF_Reference(pPDFDocument, |
| 214 pPDFDocument->AddIndirectObject(pData))); | 214 pPDFDocument->AddIndirectObject(pData))); |
| 215 } | 215 } |
| 216 fileList->push_back(std::move(pfileWrite)); | 216 fileList->push_back(std::move(pfileWrite)); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 return true; | 219 return true; |
| 220 } | 220 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 #endif // PDF_ENABLE_XFA | 301 #endif // PDF_ENABLE_XFA |
| 302 pStreamWrite->Release(); | 302 pStreamWrite->Release(); |
| 303 return bRet; | 303 return bRet; |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace | 306 } // namespace |
| 307 | 307 |
| 308 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, | 308 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, |
| 309 FPDF_FILEWRITE* pFileWrite, | 309 FPDF_FILEWRITE* pFileWrite, |
| 310 FPDF_DWORD flags) { | 310 FPDF_DWORD flags) { |
| 311 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); | 311 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); |
| 312 } | 312 } |
| 313 | 313 |
| 314 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, | 314 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, |
| 315 FPDF_FILEWRITE* pFileWrite, | 315 FPDF_FILEWRITE* pFileWrite, |
| 316 FPDF_DWORD flags, | 316 FPDF_DWORD flags, |
| 317 int fileVersion) { | 317 int fileVersion) { |
| 318 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); | 318 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); |
| 319 } | 319 } |
| OLD | NEW |