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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 } | 167 } |
168 // L"datasets" | 168 // L"datasets" |
169 { | 169 { |
170 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream()); | 170 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream()); |
171 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, | 171 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, |
172 pDsfileWrite.get(), nullptr) && | 172 pDsfileWrite.get(), nullptr) && |
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 auto pDataDict = pdfium::MakeUnique<CPDF_Dictionary>( |
178 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); | 178 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(), |
182 std::move(pDataDict)); | |
183 } | |
182 } else { | 184 } else { |
183 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); | 185 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); |
184 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); | 186 pData->InitStreamFromFile(pDsfileWrite.get(), std::move(pDataDict)); |
185 iLast = pArray->GetCount() - 2; | 187 iLast = pArray->GetCount() - 2; |
186 pArray->InsertNewAt<CPDF_String>(iLast, "datasets", false); | 188 pArray->InsertNewAt<CPDF_String>(iLast, "datasets", false); |
187 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument, | 189 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument, |
188 pData->GetObjNum()); | 190 pData->GetObjNum()); |
189 } | 191 } |
190 fileList->push_back(std::move(pDsfileWrite)); | 192 fileList->push_back(std::move(pDsfileWrite)); |
191 } | 193 } |
192 } | 194 } |
193 // L"form" | 195 // L"form" |
194 { | 196 { |
195 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); | 197 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); |
196 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), | 198 if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite.get(), |
197 pChecksum.get()) && | 199 pChecksum.get()) && |
198 pfileWrite->GetSize() > 0) { | 200 pfileWrite->GetSize() > 0) { |
199 CPDF_Dictionary* pDataDict = | 201 auto pDataDict = pdfium::MakeUnique<CPDF_Dictionary>( |
200 new CPDF_Dictionary(pPDFDocument->GetByteStringPool()); | 202 pPDFDocument->GetByteStringPool()); |
201 if (iFormIndex != -1) { | 203 if (iFormIndex != -1) { |
202 if (pFormStream) | 204 if (pFormStream) |
Lei Zhang
2016/11/18 23:50:34
curly braces, like line 180.
Tom Sepez
2016/11/19 00:05:16
Done.
| |
203 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); | 205 pFormStream->InitStreamFromFile(pfileWrite.get(), |
206 std::move(pDataDict)); | |
204 } else { | 207 } else { |
205 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); | 208 CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); |
206 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); | 209 pData->InitStreamFromFile(pfileWrite.get(), std::move(pDataDict)); |
207 iLast = pArray->GetCount() - 2; | 210 iLast = pArray->GetCount() - 2; |
208 pArray->InsertNewAt<CPDF_String>(iLast, "form", false); | 211 pArray->InsertNewAt<CPDF_String>(iLast, "form", false); |
209 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument, | 212 pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument, |
210 pData->GetObjNum()); | 213 pData->GetObjNum()); |
211 } | 214 } |
212 fileList->push_back(std::move(pfileWrite)); | 215 fileList->push_back(std::move(pfileWrite)); |
213 } | 216 } |
214 } | 217 } |
215 return true; | 218 return true; |
216 } | 219 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 FPDF_DWORD flags) { | 309 FPDF_DWORD flags) { |
307 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); | 310 return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); |
308 } | 311 } |
309 | 312 |
310 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, | 313 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, |
311 FPDF_FILEWRITE* pFileWrite, | 314 FPDF_FILEWRITE* pFileWrite, |
312 FPDF_DWORD flags, | 315 FPDF_DWORD flags, |
313 int fileVersion) { | 316 int fileVersion) { |
314 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); | 317 return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); |
315 } | 318 } |
OLD | NEW |