diff options
author | Lei Zhang <thestig@chromium.org> | 2018-09-20 16:22:12 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-09-20 16:22:12 +0000 |
commit | b739b4a9cbc991261627a51cba24907b5d0a8dd4 (patch) | |
tree | 662ff64365ab573f51d96c6927c17cb3458a4215 | |
parent | 263da7f3b44ae13345f47a6d9658b49c994bbdac (diff) | |
download | pdfium-b739b4a9cbc991261627a51cba24907b5d0a8dd4.tar.xz |
Use pdfium::Optional with FPDF_Doc_Save().
Also rename it to DoDocSave(), since it is not a public API.
Change-Id: I88992d12d1b7826c621de0b88692ab33f6d83a06
Reviewed-on: https://pdfium-review.googlesource.com/42815
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
-rw-r--r-- | fpdfsdk/fpdf_save.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp index be1dbd14f8..7d3fee9e4d 100644 --- a/fpdfsdk/fpdf_save.cpp +++ b/fpdfsdk/fpdf_save.cpp @@ -21,6 +21,7 @@ #include "fpdfsdk/cpdfsdk_filewriteadapter.h" #include "fpdfsdk/cpdfsdk_helpers.h" #include "public/fpdf_edit.h" +#include "third_party/base/optional.h" #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" @@ -215,11 +216,10 @@ bool SendPreSaveToXFADoc(CPDFXFA_Context* pContext, } #endif // PDF_ENABLE_XFA -bool FPDF_Doc_Save(FPDF_DOCUMENT document, - FPDF_FILEWRITE* pFileWrite, - FPDF_DWORD flags, - FPDF_BOOL bSetVersion, - int fileVerion) { +bool DoDocSave(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags, + Optional<int> version) { CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document); if (!pPDFDoc) return 0; @@ -237,8 +237,8 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, CPDF_Creator fileMaker( pPDFDoc, pdfium::MakeRetain<CPDFSDK_FileWriteAdapter>(pFileWrite)); - if (bSetVersion) - fileMaker.SetFileVersion(fileVerion); + if (version.has_value()) + fileMaker.SetFileVersion(version.value()); if (flags == FPDF_REMOVE_SECURITY) { flags = 0; fileMaker.RemoveSecurity(); @@ -258,7 +258,7 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document, FPDF_FILEWRITE* pFileWrite, FPDF_DWORD flags) { - return FPDF_Doc_Save(document, pFileWrite, flags, false, 0); + return DoDocSave(document, pFileWrite, flags, {}); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV @@ -266,5 +266,5 @@ FPDF_SaveWithVersion(FPDF_DOCUMENT document, FPDF_FILEWRITE* pFileWrite, FPDF_DWORD flags, int fileVersion) { - return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion); + return DoDocSave(document, pFileWrite, flags, fileVersion); } |