| 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 "../include/fpdfxfa/fpdfxfa_app.h" | 9 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 pDsfileWrite) && | 174 pDsfileWrite) && |
| 175 pDsfileWrite->GetSize() > 0) { | 175 pDsfileWrite->GetSize() > 0) { |
| 176 #ifdef XFA_USECKSUM | 176 #ifdef XFA_USECKSUM |
| 177 // Datasets | 177 // Datasets |
| 178 pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite); | 178 pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite); |
| 179 pContext->FinishChecksum(); | 179 pContext->FinishChecksum(); |
| 180 #endif | 180 #endif |
| 181 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; | 181 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; |
| 182 if (iDataSetsIndex != -1) { | 182 if (iDataSetsIndex != -1) { |
| 183 if (pDataSetsStream) | 183 if (pDataSetsStream) |
| 184 pDataSetsStream->InitStream(pDsfileWrite, pDataDict); | 184 pDataSetsStream->InitStreamFromFile(pDsfileWrite, pDataDict); |
| 185 } else { | 185 } else { |
| 186 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); | 186 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); |
| 187 pData->InitStream(pDsfileWrite, pDataDict); | 187 pData->InitStreamFromFile(pDsfileWrite, pDataDict); |
| 188 pPDFDocument->AddIndirectObject(pData); | 188 pPDFDocument->AddIndirectObject(pData); |
| 189 iLast = pArray->GetCount() - 2; | 189 iLast = pArray->GetCount() - 2; |
| 190 pArray->InsertAt(iLast, CPDF_String::Create("datasets")); | 190 pArray->InsertAt(iLast, CPDF_String::Create("datasets")); |
| 191 pArray->InsertAt(iLast + 1, pData, pPDFDocument); | 191 pArray->InsertAt(iLast + 1, pData, pPDFDocument); |
| 192 } | 192 } |
| 193 fileList.Add(pDsfileWrite); | 193 fileList.Add(pDsfileWrite); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 // L"form" | 197 // L"form" |
| 198 { | 198 { |
| 199 IFX_FileStream* pfileWrite = FX_CreateMemoryStream(); | 199 IFX_FileStream* pfileWrite = FX_CreateMemoryStream(); |
| 200 if (NULL == pfileWrite) { | 200 if (NULL == pfileWrite) { |
| 201 pContext->Release(); | 201 pContext->Release(); |
| 202 return FALSE; | 202 return FALSE; |
| 203 } | 203 } |
| 204 if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), | 204 if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), |
| 205 CFX_WideStringC(L"form"), pfileWrite, | 205 CFX_WideStringC(L"form"), pfileWrite, |
| 206 pContext) && | 206 pContext) && |
| 207 pfileWrite > 0) { | 207 pfileWrite > 0) { |
| 208 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; | 208 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; |
| 209 if (iFormIndex != -1) { | 209 if (iFormIndex != -1) { |
| 210 if (pFormStream) | 210 if (pFormStream) |
| 211 pFormStream->InitStream(pfileWrite, pDataDict); | 211 pFormStream->InitStreamFromFile(pfileWrite, pDataDict); |
| 212 } else { | 212 } else { |
| 213 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); | 213 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); |
| 214 pData->InitStream(pfileWrite, pDataDict); | 214 pData->InitStreamFromFile(pfileWrite, pDataDict); |
| 215 pPDFDocument->AddIndirectObject(pData); | 215 pPDFDocument->AddIndirectObject(pData); |
| 216 iLast = pArray->GetCount() - 2; | 216 iLast = pArray->GetCount() - 2; |
| 217 pArray->InsertAt(iLast, CPDF_String::Create("form")); | 217 pArray->InsertAt(iLast, CPDF_String::Create("form")); |
| 218 pArray->InsertAt(iLast + 1, pData, pPDFDocument); | 218 pArray->InsertAt(iLast + 1, pData, pPDFDocument); |
| 219 } | 219 } |
| 220 fileList.Add(pfileWrite); | 220 fileList.Add(pfileWrite); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 pContext->Release(); | 223 pContext->Release(); |
| 224 #endif // PDF_ENABLE_XFA | 224 #endif // PDF_ENABLE_XFA |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 FPDF_DWORD flags) { | 328 FPDF_DWORD flags) { |
| 329 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); | 329 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); |
| 330 } | 330 } |
| 331 | 331 |
| 332 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, | 332 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, |
| 333 FPDF_FILEWRITE* pFileWrite, | 333 FPDF_FILEWRITE* pFileWrite, |
| 334 FPDF_DWORD flags, | 334 FPDF_DWORD flags, |
| 335 int fileVersion) { | 335 int fileVersion) { |
| 336 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); | 336 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); |
| 337 } | 337 } |
| OLD | NEW |