Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 1857893002: Cleanup the FF Handler proxy methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 pDocument->GetDocType() != DOCTYPE_STATIC_XFA) 84 pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
85 return true; 85 return true;
86 86
87 if (!CPDFXFA_App::GetInstance()->GetXFAApp()) 87 if (!CPDFXFA_App::GetInstance()->GetXFAApp())
88 return true; 88 return true;
89 89
90 CXFA_FFDocView* pXFADocView = pDocument->GetXFADocView(); 90 CXFA_FFDocView* pXFADocView = pDocument->GetXFADocView();
91 if (!pXFADocView) 91 if (!pXFADocView)
92 return true; 92 return true;
93 93
94 CXFA_FFDocHandler* pXFADocHandler =
95 CPDFXFA_App::GetInstance()->GetXFAApp()->GetDocHandler();
96 CPDF_Document* pPDFDocument = pDocument->GetPDFDoc(); 94 CPDF_Document* pPDFDocument = pDocument->GetPDFDoc();
97 if (!pDocument) 95 if (!pDocument)
98 return false; 96 return false;
99 97
100 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); 98 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
101 if (!pRoot) 99 if (!pRoot)
102 return false; 100 return false;
103 101
104 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 102 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
105 if (!pAcroForm) 103 if (!pAcroForm)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) { 168 if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) {
171 pDataSetsStream = (CPDF_Stream*)pDataSetsDirectObj; 169 pDataSetsStream = (CPDF_Stream*)pDataSetsDirectObj;
172 } 170 }
173 } else if (pDataSetsPDFObj->IsStream()) { 171 } else if (pDataSetsPDFObj->IsStream()) {
174 pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj; 172 pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj;
175 } 173 }
176 } 174 }
177 // L"datasets" 175 // L"datasets"
178 { 176 {
179 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream()); 177 ScopedFileStream pDsfileWrite(FX_CreateMemoryStream());
180 if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), 178 if (pXFADocView->GetDoc()->SavePackage(CFX_WideStringC(L"datasets"),
181 CFX_WideStringC(L"datasets"), 179 pDsfileWrite.get()) &&
182 pDsfileWrite.get()) &&
183 pDsfileWrite->GetSize() > 0) { 180 pDsfileWrite->GetSize() > 0) {
184 // Datasets 181 // Datasets
185 pContext->UpdateChecksum(pDsfileWrite.get()); 182 pContext->UpdateChecksum(pDsfileWrite.get());
186 pContext->FinishChecksum(); 183 pContext->FinishChecksum();
187 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 184 CPDF_Dictionary* pDataDict = new CPDF_Dictionary;
188 if (iDataSetsIndex != -1) { 185 if (iDataSetsIndex != -1) {
189 if (pDataSetsStream) 186 if (pDataSetsStream)
190 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 187 pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
191 } else { 188 } else {
192 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); 189 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL);
193 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); 190 pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict);
194 pPDFDocument->AddIndirectObject(pData); 191 pPDFDocument->AddIndirectObject(pData);
195 iLast = pArray->GetCount() - 2; 192 iLast = pArray->GetCount() - 2;
196 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE)); 193 pArray->InsertAt(iLast, new CPDF_String("datasets", FALSE));
197 pArray->InsertAt(iLast + 1, pData, pPDFDocument); 194 pArray->InsertAt(iLast + 1, pData, pPDFDocument);
198 } 195 }
199 fileList->push_back(std::move(pDsfileWrite)); 196 fileList->push_back(std::move(pDsfileWrite));
200 } 197 }
201 } 198 }
202 // L"form" 199 // L"form"
203 { 200 {
204 ScopedFileStream pfileWrite(FX_CreateMemoryStream()); 201 ScopedFileStream pfileWrite(FX_CreateMemoryStream());
205 if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), 202 if (pXFADocView->GetDoc()->SavePackage(CFX_WideStringC(L"form"),
206 CFX_WideStringC(L"form"), pfileWrite.get(), 203 pfileWrite.get(), pContext.get()) &&
207 pContext.get()) &&
208 pfileWrite->GetSize() > 0) { 204 pfileWrite->GetSize() > 0) {
209 CPDF_Dictionary* pDataDict = new CPDF_Dictionary; 205 CPDF_Dictionary* pDataDict = new CPDF_Dictionary;
210 if (iFormIndex != -1) { 206 if (iFormIndex != -1) {
211 if (pFormStream) 207 if (pFormStream)
212 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); 208 pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict);
213 } else { 209 } else {
214 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL); 210 CPDF_Stream* pData = new CPDF_Stream(NULL, 0, NULL);
215 pData->InitStreamFromFile(pfileWrite.get(), pDataDict); 211 pData->InitStreamFromFile(pfileWrite.get(), pDataDict);
216 pPDFDocument->AddIndirectObject(pData); 212 pPDFDocument->AddIndirectObject(pData);
217 iLast = pArray->GetCount() - 2; 213 iLast = pArray->GetCount() - 2;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 FPDF_DWORD flags) { 320 FPDF_DWORD flags) {
325 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 321 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
326 } 322 }
327 323
328 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 324 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
329 FPDF_FILEWRITE* pFileWrite, 325 FPDF_FILEWRITE* pFileWrite,
330 FPDF_DWORD flags, 326 FPDF_DWORD flags,
331 int fileVersion) { 327 int fileVersion) {
332 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 328 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
333 } 329 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698