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

Side by Side Diff: fpdfsdk/src/fpdfsave.cpp

Issue 1477583002: Inflict PDF_ENABLE_XFA ifdefs on XFA fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Remove fsdk_actionhandler.cpp Created 5 years 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/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdftext.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 #ifdef PDF_ENABLE_XFA
9 #include "../include/fpdfxfa/fpdfxfa_app.h" 10 #include "../include/fpdfxfa/fpdfxfa_app.h"
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" 11 #include "../include/fpdfxfa/fpdfxfa_doc.h"
11 #include "../include/fpdfxfa/fpdfxfa_util.h" 12 #include "../include/fpdfxfa/fpdfxfa_util.h"
13 #endif
12 #include "fpdfsdk/include/fsdk_define.h" 14 #include "fpdfsdk/include/fsdk_define.h"
13 #include "public/fpdf_edit.h" 15 #include "public/fpdf_edit.h"
16 #ifdef PDF_ENABLE_XFA
14 #include "public/fpdf_formfill.h" 17 #include "public/fpdf_formfill.h"
18 #endif
15 19
16 #if _FX_OS_ == _FX_ANDROID_ 20 #if _FX_OS_ == _FX_ANDROID_
17 #include "time.h" 21 #include "time.h"
18 #else 22 #else
19 #include <ctime> 23 #include <ctime>
20 #endif 24 #endif
21 25
22 class CFX_IFileWrite final : public IFX_StreamWrite { 26 class CFX_IFileWrite final : public IFX_StreamWrite {
23 public: 27 public:
24 CFX_IFileWrite(); 28 CFX_IFileWrite();
(...skipping 24 matching lines...) Expand all
49 return FALSE; 53 return FALSE;
50 54
51 m_pFileWriteStruct->WriteBlock(m_pFileWriteStruct, pData, size); 55 m_pFileWriteStruct->WriteBlock(m_pFileWriteStruct, pData, size);
52 return TRUE; 56 return TRUE;
53 } 57 }
54 58
55 void CFX_IFileWrite::Release() { 59 void CFX_IFileWrite::Release() {
56 delete this; 60 delete this;
57 } 61 }
58 62
63 #ifdef PDF_ENABLE_XFA
59 #define XFA_DATASETS 0 64 #define XFA_DATASETS 0
60 #define XFA_FORMS 1 65 #define XFA_FORMS 1
61 66
62 FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, 67 FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument,
63 CFX_PtrArray& fileList) { 68 CFX_PtrArray& fileList) {
64 #ifdef PDF_ENABLE_XFA 69 #ifdef PDF_ENABLE_XFA
65 if (!pDocument) 70 if (!pDocument)
66 return FALSE; 71 return FALSE;
67 if (pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && 72 if (pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
68 pDocument->GetDocType() != DOCTYPE_STATIC_XFA) 73 pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 CXFA_EventParam preParam; 277 CXFA_EventParam preParam;
273 preParam.m_eType = XFA_EVENT_PreSave; 278 preParam.m_eType = XFA_EVENT_PreSave;
274 pWidgetHander->ProcessEvent(pWidgetAcc, &preParam); 279 pWidgetHander->ProcessEvent(pWidgetAcc, &preParam);
275 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 280 pWidgetAcc = pWidgetAccIterator->MoveToNext();
276 } 281 }
277 pWidgetAccIterator->Release(); 282 pWidgetAccIterator->Release();
278 pXFADocView->UpdateDocView(); 283 pXFADocView->UpdateDocView();
279 return _SaveXFADocumentData(pDocument, fileList); 284 return _SaveXFADocumentData(pDocument, fileList);
280 } 285 }
281 286
287 #endif
282 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, 288 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,
283 FPDF_FILEWRITE* pFileWrite, 289 FPDF_FILEWRITE* pFileWrite,
284 FPDF_DWORD flags, 290 FPDF_DWORD flags,
285 FPDF_BOOL bSetVersion, 291 FPDF_BOOL bSetVersion,
286 int fileVerion) { 292 int fileVerion) {
287 CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document); 293 CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document);
288 if (!pPDFDoc) 294 if (!pPDFDoc)
289 return 0; 295 return 0;
290 296
297 #ifdef PDF_ENABLE_XFA
291 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; 298 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
292 CFX_PtrArray fileList; 299 CFX_PtrArray fileList;
293 _SendPreSaveToXFADoc(pDoc, fileList); 300 _SendPreSaveToXFADoc(pDoc, fileList);
294 301
302 #endif
295 if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) { 303 if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) {
296 flags = 0; 304 flags = 0;
297 } 305 }
298 306
299 CPDF_Creator FileMaker(pPDFDoc); 307 CPDF_Creator FileMaker(pPDFDoc);
300 if (bSetVersion) 308 if (bSetVersion)
301 FileMaker.SetFileVersion(fileVerion); 309 FileMaker.SetFileVersion(fileVerion);
302 if (flags == FPDF_REMOVE_SECURITY) { 310 if (flags == FPDF_REMOVE_SECURITY) {
303 flags = 0; 311 flags = 0;
304 FileMaker.RemoveSecurity(); 312 FileMaker.RemoveSecurity();
305 } 313 }
306 314
307 CFX_IFileWrite* pStreamWrite = NULL; 315 CFX_IFileWrite* pStreamWrite = NULL;
308 FX_BOOL bRet; 316 FX_BOOL bRet;
309 pStreamWrite = new CFX_IFileWrite; 317 pStreamWrite = new CFX_IFileWrite;
310 pStreamWrite->Init(pFileWrite); 318 pStreamWrite->Init(pFileWrite);
311 bRet = FileMaker.Create(pStreamWrite, flags); 319 bRet = FileMaker.Create(pStreamWrite, flags);
320 #ifdef PDF_ENABLE_XFA
312 _SendPostSaveToXFADoc(pDoc); 321 _SendPostSaveToXFADoc(pDoc);
313 for (int i = 0; i < fileList.GetSize(); i++) { 322 for (int i = 0; i < fileList.GetSize(); i++) {
314 IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i); 323 IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i);
315 pFile->Release(); 324 pFile->Release();
316 } 325 }
317 fileList.RemoveAll(); 326 fileList.RemoveAll();
327 #endif
318 pStreamWrite->Release(); 328 pStreamWrite->Release();
319 return bRet; 329 return bRet;
320 } 330 }
321 331
322 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, 332 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document,
323 FPDF_FILEWRITE* pFileWrite, 333 FPDF_FILEWRITE* pFileWrite,
324 FPDF_DWORD flags) { 334 FPDF_DWORD flags) {
325 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 335 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
326 } 336 }
327 337
328 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 338 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
329 FPDF_FILEWRITE* pFileWrite, 339 FPDF_FILEWRITE* pFileWrite,
330 FPDF_DWORD flags, 340 FPDF_DWORD flags,
331 int fileVersion) { 341 int fileVersion) {
332 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 342 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
333 } 343 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdftext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698