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>
diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp
index be1dbd1..7d3fee9 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 @@
}
#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 @@
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 @@
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_FILEWRITE* pFileWrite,
FPDF_DWORD flags,
int fileVersion) {
- return FPDF_Doc_Save(document, pFileWrite, flags, true, fileVersion);
+ return DoDocSave(document, pFileWrite, flags, fileVersion);
}