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

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

Issue 1255693002: Revert "FX_BOOL considered harmful, part 2." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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/src/fpdfppo.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_edit.h" 7 #include "../../public/fpdf_edit.h"
8 #include "../../public/fpdf_save.h" 8 #include "../../public/fpdf_save.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 10
11 #if _FX_OS_ == _FX_ANDROID_ 11 #if _FX_OS_ == _FX_ANDROID_
12 #include "time.h" 12 #include "time.h"
13 #else 13 #else
14 #include <ctime> 14 #include <ctime>
15 #endif 15 #endif
16 16
17 class CFX_IFileWrite final : public IFX_StreamWrite 17 class CFX_IFileWrite final : public IFX_StreamWrite
18 { 18 {
19 19
20 public: 20 public:
21 CFX_IFileWrite(); 21 CFX_IFileWrite();
22 bool Init( FPDF_FILEWRITE * pFileWriteStruct ); 22 FX_BOOL Init( FPDF_FILEWRITE * pFileWriteStruct );
23 virtual bool WriteBlock(const void* pData, size_t size) override; 23 virtual FX_BOOL WriteBlock(const void* pData, size_t size) override;
24 virtual void Release() override {} 24 virtual void Release() override {}
25 25
26 protected: 26 protected:
27 FPDF_FILEWRITE* m_pFileWriteStruct; 27 FPDF_FILEWRITE* m_pFileWriteStruct;
28 }; 28 };
29 29
30 CFX_IFileWrite::CFX_IFileWrite() 30 CFX_IFileWrite::CFX_IFileWrite()
31 { 31 {
32 m_pFileWriteStruct = NULL; 32 m_pFileWriteStruct = NULL;
33 } 33 }
34 34
35 bool CFX_IFileWrite::Init( FPDF_FILEWRITE * pFileWriteStruct ) 35 FX_BOOL CFX_IFileWrite::Init( FPDF_FILEWRITE * pFileWriteStruct )
36 { 36 {
37 if (!pFileWriteStruct) 37 if (!pFileWriteStruct)
38 return false; 38 return FALSE;
39 39
40 m_pFileWriteStruct = pFileWriteStruct; 40 m_pFileWriteStruct = pFileWriteStruct;
41 return true; 41 return TRUE;
42 } 42 }
43 43
44 bool CFX_IFileWrite::WriteBlock(const void* pData, size_t size) 44 FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size)
45 { 45 {
46 if (!m_pFileWriteStruct) 46 if (!m_pFileWriteStruct)
47 return false; 47 return FALSE;
48 48
49 m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size ); 49 m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size );
50 return true; 50 return TRUE;
51 } 51 }
52 52
53 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF _DWORD flags, FPDF_BOOL bSetVersion, 53 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF _DWORD flags, FPDF_BOOL bSetVersion,
54 int fileVerion) 54 int fileVerion)
55 { 55 {
56 CPDF_Document* pDoc = (CPDF_Document*)document; 56 CPDF_Document* pDoc = (CPDF_Document*)document;
57 if (!pDoc) 57 if (!pDoc)
58 return 0; 58 return 0;
59 59
60 if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY ) 60 if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
61 { 61 {
62 flags = 0; 62 flags = 0;
63 } 63 }
64 64
65 CPDF_Creator FileMaker(pDoc); 65 CPDF_Creator FileMaker(pDoc);
66 if(bSetVersion) 66 if(bSetVersion)
67 FileMaker.SetFileVersion(fileVerion); 67 FileMaker.SetFileVersion(fileVerion);
68 if(flags == FPDF_REMOVE_SECURITY) 68 if(flags == FPDF_REMOVE_SECURITY)
69 { 69 {
70 flags = 0; 70 flags = 0;
71 FileMaker.RemoveSecurity(); 71 FileMaker.RemoveSecurity();
72 } 72 }
73 CFX_IFileWrite* pStreamWrite = NULL; 73 CFX_IFileWrite* pStreamWrite = NULL;
74 bool bRet; 74 FX_BOOL bRet;
75 pStreamWrite = new CFX_IFileWrite; 75 pStreamWrite = new CFX_IFileWrite;
76 pStreamWrite->Init( pFileWrite ); 76 pStreamWrite->Init( pFileWrite );
77 bRet = FileMaker.Create(pStreamWrite, flags); 77 bRet = FileMaker.Create(pStreamWrite, flags);
78 delete pStreamWrite; 78 delete pStreamWrite;
79 return bRet; 79 return bRet;
80 } 80 }
81 81
82 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILE WRITE * pFileWrite, 82 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILE WRITE * pFileWrite,
83 FPDF_DWORD flags ) 83 FPDF_DWORD flags )
84 { 84 {
85 return _FPDF_Doc_Save(document, pFileWrite, flags, false , 0); 85 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0);
86 } 86 }
87 87
88 88
89 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_ FILEWRITE * pFileWrite, 89 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_ FILEWRITE * pFileWrite,
90 FPDF_DWORD flags, int fileVersion) 90 FPDF_DWORD flags, int fileVersion)
91 { 91 {
92 return _FPDF_Doc_Save(document, pFileWrite, flags, true , fileVersion); 92 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion);
93 } 93 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfppo.cpp ('k') | fpdfsdk/src/fpdftext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698